SE450: Types: Abstraction [32/47] |
We can look at an object at progressively more abstract types.
Consider java.util.LinkedList:
file:types/abstractTypes/Main.java [source] [doc-public] [doc-private]
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
package types.abstractTypes; public class Main { private Main() {} public static void main(String[] args) { java.util.LinkedList<?> o1 = new java.util.LinkedList<>(); java.util.AbstractSequentialList<?> o2 = o1; java.util.AbstractList<?> o3 = o1; java.util.AbstractCollection<?> o4 = o1; java.lang.Object o5 = o1; java.util.List<?> i1 = o1; java.util.Collection<?> i2 = o1; java.io.Serializable i3 = o1; java.lang.Cloneable i4 = o1; } }
There are nine references to a single object.
Each reference has a different set of capabilities.