Please enable JavaScript.
Coggle requires JavaScript to display documents.
Objects in Python and Java - Coggle Diagram
Objects in Python and Java
Python
Variable
Stores
Reference
Several variables may store the same reference
Points to
Value
Getting the reference
id(variable)
Modifying
Immutable objects
A new reference is created, so other objects with the original reference are not affected.
Mutable objects
The reference is kept, so the value changes for every object with the same reference.
Copying
a = b
The reference is copied to the destination variable.
Checking identity
id(obj1) == id(obj2)
obj1 is obj2
Java
Variable
Primitive Type
Stores
Value
Reference Type
Stores
Reference
May be null
Points to
Value
Getting the reference
System.out.println(variable);
Several variables may store the same reference
is
Instance of a class