Sample program:
class Sample {
public static void main(String args[ ] ) {
System.out.println("Sample") ;
}
}
Program explanation:
Keyword used in line 1- class
The name of the class(Identifier) - Sample
Class enclosed in - { }
Program execution begins with- main()
Access modifier-public
static-allows main() method to be called without having an instance of class.
void-main() doesn't have a return value.
main() - called when java application begins execution
String args[]- args is a parameter-array of instances of class String
args- receives command line arguments.
System- predefined class
out - output stream connected to console
Println- displays strings passed to it.
; - semicolon ends the statement.