Contents

  1. ./First.java
  2. ./Hello.java

./First.java 1/2

[
top][prev][next]
/**
 * This class demonstrates some basic Java syntax.
 * Note that this code is "overcommented".  I am trying to explain
 * the code to you.  You should not need this many comments in your code.
 * However, if the comments are helpful to you, you can continue with them.
 *
 * 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!"); // Statements end with ;
   }
}

./Hello.java 2/2

[
top][prev][next]
/**
 * Our first Java class
 *
 * 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.print("Hello, World!"); // Statements end with ;
       System.out.println("More stuff!"); // Statements end with ;
   }
}

Generated by GNU Enscript 1.6.5.90.