Existence Guild
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Tutorial 1: Hello Java

Go down

Tutorial 1: Hello Java Empty Tutorial 1: Hello Java

Post by Choti Sat Mar 05, 2011 7:19 am

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.
Choti
Choti
Ancient
Ancient

Posts : 282
Join date : 2010-01-16
Age : 34
Location : Scotland,Uk away from Rose =(

https://existenceguild.forumotion.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum