Structure of a simple Java Program
![undefined](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9zZrDV2Kh-uqWVnk2aIXEli0-uPzQMMByh8YCWgsjgQrXbNPqkMjtyU8XlHz2a3SwEJYh6cu6e6G56MVwCg3fY02lcw1u0VrGpQS3SSohseRsEt38QorNOP8O9BcPz4ZDHBmL3Cw421Qx/s1600/JavaCompileAndExec.gif)
•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
![undefined](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi9zZrDV2Kh-uqWVnk2aIXEli0-uPzQMMByh8YCWgsjgQrXbNPqkMjtyU8XlHz2a3SwEJYh6cu6e6G56MVwCg3fY02lcw1u0VrGpQS3SSohseRsEt38QorNOP8O9BcPz4ZDHBmL3Cw421Qx/s1600/JavaCompileAndExec.gif)
•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