Tutorial 1: Hello Java
Existence Guild :: Tutorials :: Programming :: Java
Page 1 of 1
Tutorial 1: Hello Java
- Code:
/** This is a documentation comment.
* you can have multiple lines of this.
*/
/* This is a comment.
* you can have multiple lines of this.
*/
//This is another comment
import java.util.*;
public class HelloJava
{
public static void main(String [] args)
{
System.out.println("Sup JAVA");
System.out.println(new Date());
}
}
Ok so thats the code. Let me explain some stuff though.
public static void main(String [] args) <--this is our main method
{
System.out.println("Sup JAVA"); <---these are statements
System.out.println(new Date()); <---
}
In Java every application must contain a main method. You will need that line in every program you make.
We have two statements in our main method. The first one is used to print "Sup JAVA" and the second one gives us the date. Notice how the statements end with a ';'. If you dont have those your program will not compile and you'll get an error. Also notice after our main method we have curly braces. { }. After every method you need a set of curly braces. Your code for that method needs to go between the braces.
Existence Guild :: Tutorials :: Programming :: Java
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|