![]() The primitive types exist either as local variables on the stack, or as fields (static or not) of objects. ![]() This means that there are primitive types, originally designed for speed, that do not behave as objects. Java has two different types of variables: primitive and objects and only objects are reference types. So in the above example, x is an int, a primitive, and therefore cannot be dereferenced - meaning x.anything is invalid syntax in Java. So you cannot do somePrimitive.something(). Primitives (byte, char, short, int, long, float, double, boolean) are not objects and do not have member variables or methods. Test.java:5: error: int cannot be dereferenced Since, int is already a value (not a reference), it can not be dereferenced. Dereferencing is the process of accessing the value referred to by a reference. ![]() ![]() The type int is a primitive and not an object. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |