Monday 24 November 2014

Beginning Programming
Code to Execute
To repeat what we discussed in the last section, the program containing source code always has extension .java. The Java compiler always generates bytecode with same name and has an extension .class. The class file processed by the JVM and produces output. It is a rule that the source file name must match with the class name inside the file.
Source file
Class name
Byte code
HelloWorld.java
HelloWorld
HelloWorld.class
AddNumbers.java
AddNumbers
AddNumbers.class
Average.java
Average
Average.class
 In a Java application, execution starts with the main method. We have already used this method and will understand it better later in the course. You must have heard that Java is "platform independent". What does this mean? This means that you can write Java code on some system, say a Windows machine, and compile it. Then you can take the classfile generated and run it on any other system (Linux, Unix, MAC, or another Windows) and the code will run!

No comments:

Post a Comment