int cannot be dereferenced in java code example

Example 1: int cannot be dereferenced???

Primitives (byte, char, short, int, long, float, double, boolean) are not 
objects and do not have member variables or methods. They're just simple values.
So you cannot do somePrimitive.something() . So in the above example, x is an 
int, a primitive, and therefore cannot be dereferenced - meaning x.anything is 
invalid syntax in Java.

Example 2: variable cannot be dereferenced java

Java has two different types of variables: primitive and objects and only objects are reference types. The type int is a primitive and not an object. Dereferencing is the process of accessing the value referred to by a reference . Since, int is already a value (not a reference), it can not be dereferenced.

Tags:

Java Example