public class Cell {
public int v;
}
public class Helper {
public static void bump(Cell c) {
c.v++;
}
}
// ...
Cell c = new Cell();
c.v = 10;
Helper.bump(c);
System.out.println(c.v);What is printed?
- Acheck_circle
11
- B
10
- C
0
- D
Compile-time error
Explanation
The reference is passed by value; bump modifies the same object's field through that reference.