Next: Second program
Up: Unit 01
Previous: Java
import java.lang.*;
public class First {
public static void main(String[] args) {
System.out.println("This is my first Java program.");
}
}
The statements have the following meaning:
- import java.lang.*; request to use libraries of predefined
classes/programs (in fact, the java.lang library is imported
automatically, hence this statement can be omitted)
- public class First {...} definition of a class/program called
First
- public static void main(String[] args) {...} definition of the
main method (a method is the realization of an operation in Java)
- System.out.println("This is my first Java program."); statement
to print a message on the video
- System.out predefined object/instance of the predefined class
PrintStream
- println method of the class PrintStream applied to the
object System.out
- "This is my first Java program." object of the class
String representing the sentence to display
Note: Java is case-sensitive, i.e., there is a
difference between lower-case and upper-case letters. E.g., class
is different from Class.
Next: Second program
Up: Unit 01
Previous: Java