/**
* Today program that prints a quote
*
* @author Suzanne Balik, 10 Aug 2003
*/
public class Today {
public static void main (String[] args) {
System.out.println("Today is the first day of the rest of your life.");
// This is a comment.
/* Here is another type of comment
that can span one or
more lines */
}
}
csc% javac Today.java csc% java Today Today is the first day of the rest of your life.
public class Today {
public static void main (String[] args) {
System.out.println("Today is the first day " +
"of the rest of your life.");
}
}
public class Today {
public static void main (String[] args) {
System.out.print("Today is the first day ");
System.out.println("of the rest of your life.");
}
}
public class Today {
public static void main (String[] args) {
System.out.print("Today is the first day ")
System.out.println("of the rest of your life.);
}
}
csc% javac Today.java
Today.java:5: ';' expected
System.out.print("Today is the first day ")
^
Today.java:6: unclosed string literal
System.out.println("of the rest of your life.);
public class Today {
public static void MAIN (String[] args) {
System.out.print("Today is the first day ");
System.out.println("of the rest of your life.");
}
}
csc% javac Today.java
csc% java Today
Exception in thread "main" java.lang.NoSuchMethodError: main
public class Zero {
public static void main(String[] args) {
System.out.println( 24 / 0);
}
}
csc% javac Zero.java
csc% java Zero
Exception in thread "main" java.lang.ArithmeticException: / by zero
at Zero.main(Zero.java:5)
public class Today {
public static void main (String[] args) {
System.out.println("Toy is the fit day of the rest of yor life.");
}
}
csc% javac Today.java
csc% java Today
Toy is the fit day of the rest of yor life.
public class Average {
public static void main (String[] args) {
System.out.println("Average: " + ( 3 + 4 + 1 + 4) / 3 );
}
}
csc% javac Average.java
csc% java Average
Average: 4