Contents
- ./First.java
- ./Hello.java
./First.java 1/2
[top][prev][next]
/**
* This class demonstrates some basic Java syntax
*
* All code in a Java program must belong to a class.
* There is typically one class per file, and the file name is ClassName.java
* Compile this code using
* javac First.java
* Run the compiled bytecode First.class using
* java First
*
* @author Sara Sprenkle
*/
public class First { //File must be saved as First.java
/**
* Called when user runs
* java First
*/
public static void main(String[] args) { //Blocks start/end with {}
System.out.println("This is my first Java program!"); //Lines end with ;
System.out.println("To print a \\, you must use \"\\\\\"");
}
}
./Hello.java 2/2
[top][prev][next]
/**
* Our first Java class! It displays "Hello, World!".
*
* All code in a Java program must belong to a class.
* There is typically one class per file, and the file name is ClassName.java
* Compile this code using
* javac Hello.java
* Run the compiled bytecode Hello.class using
* java Hello
*
* @author Sara Sprenkle
*/
public class Hello { //File must be saved as Hello.java
/**
* Called when user runs
* java Hello
*/
public static void main(String[] args) { // Blocks start/end with {}
System.out.println("Hello, World!"); // Lines end with ;
}
}
Generated by GNU Enscript 1.6.6.