/**
* FirstClass.java
*/
package mypackage;
import java.io.System;
public class FirstClass() {
public static void main(String[] args) {
printout();
}
public void printOut() {
System.out.println(str);
}
private String str = “Hello, World!”;
}
It is the first class writing in Java.
There can be only one public class in one source file and this class name must be the same with the file name.
The “public class FirstClass()” is to declare an class. It is the head of the class and the content in {} is the body of the class.
The “public static void main(String[] args)” is the main() method. It is the entrance of a programme. Only the programmes which have main() method can be executed. The definition of main() method is only this way. The main() method is not a behavior.
The “public void printOut()” is a method of the class and the “private String str” is a field of the class.