1 2 Simple Java Program
1 2 Simple Java Program
- To compile the Example program, execute the compiler, javac, specifying the name of the
source file on the command line, as shown here
- C:\>javac Example.java
- The javac compiler creates a file called Example.class that contains the bytecode version
of the program
- To run the program, you must use the Java application launcher called java
- To do so, pass the class name Example as a command-line argument, as shown here:
- C:\>java Example
A Closer Look at the First Sample Program
- /*
This is a simple Java program.
Call this file "Example.java".
*/
- This is a comment
- The contents of a comment are ignored by the compiler
- Java supports three styles of comments
- The one shown at the top of the program is called a multiline comment
- This type of comment must begin with /* and end with */.
- Anything between these two comment symbols is ignored by the compiler
A Closer Look at the First Sample Program