Neither of those is equivalent to the programming "problem" Mike set up in his previous post, and both of them display the same consistent behaviour.
In the first program, you're modifying the
PImage object that, within the scope of the method
blackImage(), is referenced by both the
img field and
myImage local variable. You cannot change that actual object that
img points to by changing what
myImage points to. You can only change the
content of that object. This is because the reference
img, which you passed as an argument to
blackImage(), was copied. This is pass by value. Again,
it's the reference to the PImage object that is being passed. In
Java, you never pass the object itself.
In the second program, the behaviour is the same:
a will be 12 unless you explicitly reassign
a.
myInteger is a copy of a in the scope of the method
blackInteger() because it too was passed by value.