Google+

181. Non-primitive Data Types







The following are the Non-Primitive Data Types in Java -



Non-Primitive Data Types are also called as Reference Data Types as the address of the objects or Arrays is stored in a reference variable.

Car audi = new Car( );

Here audi is the reference variable in which the address of the Car's object is stored.

Example for User defined Class Non-Primitive Data Type

Car benz = new Car( );

Here benz is an identifier which is defined of Car data Type (i.e. Car Class Data Type).

Car is a User defined Class and hence we can call it as User defined Class Data Type.

Here benz identifier refers to the object memory location of User defined Car Class.

Example for Predefined Class Non-Primitive Data Type

String name ="Arun";

Here name is an identifier which is defined of String data type (i.e. Predefined String Class Data Type)

String is a predefined Class of Java and hence we can call it as Predefined Class Data Type.

Here name identifier refers to the object memory location of Predefined String Class.

Example for Arrays Non-Primitive Data Type

int var[] = new int[5];

Here var is an identifier which is defined of Array data type by specifying [] beside the identifier.

An array is a special kind of object reference that contains values called elements.

var  is a reference variable which refers to the object location of the Array.

Hence Classes, Interfaces and Arrays are the Non-Primitive Data Types in Java.




Please comment below to feedback or ask questions.

Local Variables and Instance Variables will be explained in the next post.





No comments: