Slef- referential Class

 In order to design a node a special type of class is used often called as Self-referential class i.e., A class having a variable 

of same class type.

class Link 

{

------

------ //Data

------

Link next;

}

Ex:- 

class Link

{

 public int rollNo;

 public String name;

 public Link next;

 public Link (int rNo, String n)

 {

 rollNo=rNo;

 name=n;

 }

 public void displayLink ()

 {

 System.out.print("{"+rollNo+","+name+"}");

 }

}

Comments

Post a Comment

Popular posts from this blog

How to know your ip address?

What is java?