Why increment method does not increment the object parameter value?
Hi everyone, Could anyone explain me the reason why incrementA method does not increment the parameter value here? I changed method type, method parameter type but the result does not change. public class Program { public int a; private double b; public Program(int first, double second) { this.a = first; this.b = second; } public static void incrementA(int first) { first = first + 1; } public static void incrementA(double second) { second = second + 1; } public static void incrementBoth(Program obj) { obj.a = obj.a + 1; obj.b = obj.b + 1; } public static void main(String[] args) { Program myObj1 = new Program(10, 15.6); Program myObj2 = new Program(10, 20.5); incrementA(myObj1.a); System.out.println(myObj1.a); } }