Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Java Jdk7 Reference Data Types

Related Tutorials


 
 

Share on Google+Share on Google+

Reference Data Types

Advertisement
In this section we will discuss about Reference Data Types in Java 7.

Reference Data Types

In this section we will discuss about Reference Data Types in Java 7.

Reference Data Types :

Non-primitive data types are also called reference data types. It is handled by reference. These refer to objects and arrays. it is created by defining constructor of a classes. You can use it to access the objects. Class objects and different type of array variables are described in reference data type.

You can define reference data type as a variable that can contain reference of dynamically created object. These are not predefined like primitive data type.
These are -

  • array
  • class
  • interface

Array Type :
In general, array is a collection of similar type of data types.

Syntax :

DataType[] arrayVariable=new DataType[];

Example :

int[] n=new int[5];
String[] str=new String();

class Type :

Class is a template of variables and methods. Name of class refers as a type in java. By creating object of this class you can access class variables and methods.

Example :

Test.java

class Test{
int a=100;
public void display(){
System.out.println("Value of a:" +a);
}
}

MainClass.java

Class MainClass{
public static void main(String[] args){
Test test=new Test();
test.display();
}
}

Interface Type:
The another type of reference data type is Interface Type. It supports concept of multiple inheritance. You can use name of interface as type of reference.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 18, 2012

Related Tutorials

Discuss: Reference Data Types  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com