A Closer Look at the Example.java

Here is the code we just created.


/* 
 This is a simple Java program. Call this file "Example.java". 
 */

public class Example {
  // Your program begins with a call to main().
  public static void main(String args[]) {
    System.out.println("Java.");
  }
}

The first part is a comment.


/* 
   This is a simple Java program. Call this file "Example.java". 
*/ 

Comment is a remark for a program. The contents of a comment are ignored by the compiler. The next line of code in the program is shown here:


public class Example { 

The keyword class declares that a new class is being defined.

Example is the name of the class.

The entire class definition is between the opening curly brace ({) and the closing curly brace (}). The next line in the program is the single-line comment, shown here:


// Your program begins with a call to main(). 

A single-line comment begins with a // and ends at the end of the line. The next line of code is shown here:


public static void main(String args[]) { 

Java applications begin execution by calling main(String args[]). Java is case-sensitive. Thus, Main is different from main.

java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.