Apologies for asking such a primitive question.
I wrote a function which took one parameter; this parameter was supposed to be an in/out parameter.
After d
Integer is immutable, that's why its value cant be changed.
why doesn't the compiler (interpreter?) complain when I do currentFoo = currentFoo + 1
because when u do currentFoo = currentFoo + 1 a new Integer is created on heap and its reference is assigned to the currentFoo.
For Integer, if you want to get changed value outside the function, either you can return the value from the function, OR you can put the integer into array/ArrayList and pass that array/ArrayList to the function. Now get change the value, it will be reflected outside the function.