Structure of a simple Java Program

•Everything must be in a class.
•Java applications (not Applets) must have a main()routine in one of the classes with the signature: –public static void main(String [] args)
class HelloWorld
{
public static void main(String [] args) {
System.out.println(“Hello World!”);
}
}
Compiling and Running the“Hello World” Program
•Compile: –javac HelloWorld.java
•Run: –javaHelloWorld •Output: –“Hello World”
Java Virtual Machine
•Java programs run on a Java Virtual Machine.
•Features: –Security –Portability –Superior dynamic resource management –Resource location transparency –Automatic garbage collection

•Everything must be in a class.
•Java applications (not Applets) must have a main()routine in one of the classes with the signature: –public static void main(String [] args)
class HelloWorld
{
public static void main(String [] args) {
System.out.println(“Hello World!”);
}
}
Compiling and Running the“Hello World” Program
•Compile: –javac HelloWorld.java
•Run: –javaHelloWorld •Output: –“Hello World”
Java Virtual Machine
•Java programs run on a Java Virtual Machine.
•Features: –Security –Portability –Superior dynamic resource management –Resource location transparency –Automatic garbage collection
0 comments:
Post a Comment