arrows pointing right and left

Java Cheat Sheet
Mark 4


email Scott Turner
home
programming
types, objects (capitalized) vs. primitive types (lower case)
generic expressions
s ? x : y
(x)
numbers (int, double, Integer, Double)
0, 1, -1, ...
1.0, 2.0, 1.5, 0.6666, ...
a + b
a - b
- a
a * b
a / b
Math.abs(a)
Math.pow(a, b)
Math.sin(a) [etc.]
sentences (boolean, Boolean)
false
true
a == b
a != b
a < b
a <= b
a >= b
a > b
s && t
s || t
! s
objects (Object)
a.equals(b)
a == null
strings (String)
"whatever"
s + t
a.toString()
Integer(s)
Integer(s).intValue()
Double(s)
Double(s).doubleValue()
function definitions
static type2 functionName(type1 x) {
    action1;
    action2;
    return ... x ...;
}
variables and arrays
array types
type []
reserving storage
type name;
type name = y;
new type [arraySize]
type [] arrayName = new type [arraySize];
fetching value
name
name[index]
assignment
name = expression;
name[index] = expression;
actions
if (s) {
    action;
}
if (s) {
    action1;
}
else {
    action2;
}
for (k=0; k<n; k = k+1) {
    action;
}
x = y;
I/O
Gak! In Java I/O is normally event driven, and much more complex than Haskell. Use the boilerplate code.

Support open standards!  
Valid XHTML 1.0!