You can use varargs for optional parameters:
public class Booyah {
public static void main(String[] args) {
woohoo(1);
woohoo(2, 3);
}
static void woohoo(int required, Integer... optional) {
Integer lala;
if (optional.length == 1) {
lala = optional[0];
} else {
lala = 2;
}
System.out.println(required + lala);
}
}
Also it's important to note the use of Integer over int. Integer is a wrapper around the primitive int, which allows one to make comparisons with null as necessary.