next up previous
Next: Method calls Up: Unit 02 Previous: Summary

A simple Java program

Consider the following Java program:

public class MyMessage {
  public static void main(String[] args) {
    //What does this program do?
    /* Do you know it?
       It's easy. */
    System.out.println("JA");
    System.out.println("VA");
  }
}

Form of the program

The indentation has no effect at all on the execution of the program. However, for readability of the code, it is very important to use proper indentation.

Comments

It is possible to annotate the text of the program with comments. In Java we can make use of two types of comments:

Comments have no effect on the execution of the program. Again, they are used to improve the readability of the program code.

Other properties of Java

Note: typically, Java adopts the convention that class names start with a capital letter, and method names with a lowercase letter. You better respect this convention, if you want your programs to be understood.


next up previous
Next: Method calls Up: Unit 02 Previous: Summary