Other cheat sheets: Jython/Python
General Language Notes
Statically Typed
Use semicolons to delimit statements.
Null is null.
Block structure determined by curly braces:
eg:
// sample if-then-else
if (x == y && y != z) {
System.out.println("condition true");
}
else {
System.out.println("condition false");
}
Printing to standard output
Printing is a method call.
Examples:
System.out.println("hello");
System.out.println("x = " + x);
Defining a Class
# define a java class
public class MyClass {
private int x;
public MyClass(int x) {
// initialize instance var x
this.x = x;
}
public void myMethod() {
System.out.println("myMethod");
}
}