There are eight primitive types in
Java, of which seven are numbers:-
longintshortbytedoublefloat, andchar. Yes "char" is a number, from 0 to 65535, even though it is usually shown as a character.Also
boolean.When you pass a primitive type as an argument to a method you pass its actual value.
At the end of that imaginary snippet the bar method receives the value 123, which it can do whatever it likes with. There is no way of altering the original value of "foo."
Anything which isn't one of those eight primitive types shown above, that you can give a name (identifier) to, is an object. Similar code (copy and paste from above, with a few changes).
Now what you pass to the bar() method is still a number, but not "123;" it is a number which represents where to find a reference to "foo" (which is why objects are also called reference types). Now the "bar()" method can get its hands on a reference to "foo" and can manipulate the object which we have called "foo." It can for example change the 123 to 246.
Where are you learning? Have you not been told about objects in your lectures or classes? Have you not found the Java tutorial which I gave a link to in the reply to your other question? Have you not got a simple book which introduces objects?