In Java, consider the declaration and initialization
Object obj = new Object();
In the process, we have created an object called Object in some memory location, and we bind the memory location to the variable obj.
Now consider the declaration and initialization of a primitive type in java:
int num1Java = 5;
int num2Java = num1Java;
We again bind each of them to the memory locations of 5; yes, I said memory locations because Java seems to treat primitive types differently, it creates another instance of 5 at another memory location and then binds num2Java to that new location containing the same information, namely 5. Am I right here?
Consider the similar code in Python, which prints out true:
num1Py = 5
num2Py = num1Py
print id(num1Py)==id(num2Py)
The lesson seems to be that in Python, "primitive types" like integers are treated as objects in Java sense, in other words, in python, we do not have the concept of "primitive type". Am I right?
I browsed a lot of web on related topics, but none seem to give a completely satisfactory answer. Help is greatly appreciated.