public static void main(String args[]) { functionOne(); // call function without parameters int x = 3; int y = 9; int z; z = addtwonumbers(x, y); // x and y are pass by value System.out.println(x); System.out.println(y); IntClass a = new IntClass(); // Reference through instances IntClass b = new IntClass(); // of classes a.setNum(3); b.setNum(9); addtwonumbers(a, b); // a and b are pass by reference System.out.println(a.getNum() + b.getNum()); }
public static void addtwonumbers(IntClass x, IntClass y) { x.addtoNum(100); y.addtoNum(200); }