
上QQ阅读APP看书,第一时间看更新
Reference types
Like most modern programming languages, JVM does not work with direct memory pointers to objects; it uses reference types. A reference type variable either points to a specific instance of a class or it points to nothing.
If a reference type points to an object, it can be used to call the object's methods or access public attributes.
If a reference type points to nothing, it is called a null reference. When calling methods or reading attributes using a null reference, an error will be generated at runtime. We will see that some languages covered in this book came up with solutions to this common problem.