What is the difference between being shallowly and deeply equal? How is this applied to caching?
Found the following in my notes, but I am unable to make sense of it: Primitive type wrapper classes implement caching for a limited number of values. This guarantees that a limited number of deeply equal wrapper objects are also shallowly equal: If o1.equals( o2 ) then o1 == o2 . For example, new Integer( 0 ) == new Integer( 0 ) . In general this does not always work. For example, new Integer( 666 ) == new Integer( 666 ) may not hold. The reason for caching is that it saves memory. In general caching works for “small” primitive values. I don't understand what is meant by this, or what the