HW5 will start after the break and will be done in pairs.
You partner must be from your lab section.
Pair Programming: you'll have to work together so pick someone with a compatible schedule.
You'll have a different partner for HW6. You cannot re-use partners.
You can usually pick your partner, but your lab TA has the final say.
See these slides.
public static int add(int a, int b) { return a + b; }
Because Java passes a method values as its arguments (i.e., copies of what was in the variable, not the variable itself) there is no way to write a swap method:
public static void swapAttempt(int a, int b) { System.out.println("Swap attempt called with " + a+", "+b); int c = a; a = b; b = c; System.out.println("Swap attempt finished with " + a+", "+b+", "+c); } public static void main(String[] args) { int a = 3; int b = 4; int c = 5; System.out.println("Main has " + a + ", " + b + ", " + c); swapAttempt(a,b); System.out.println("Main has " + a + ", " + b + ", " + c); swapAttempt(b,a); System.out.println("Main has " + a + ", " + b + ", " + c); }
Try Coding Bat to practice writing methods.