Web hosting reseller - Chapter 23 Data Structures and Collections 1147 clared
Chapter 23 Data Structures and Collections 1147 clared here hence, the term self-referential class. Member nextis referred to as a link (i.e., nextcan be used to tie an object of type Nodeto another object of the same type). Class Node also has two properties: One for variable data (named Data), and another for variable next(named Next). Self-referential objects can be linked together to form useful data structures, such as lists, queues, stacks and trees. Figure 23.2 illustrates two self-referential objects linked together to form a list. A backslash (representing a null reference) is placed in the link member of the second self-referential object to indicate that the link does not refer to another object. The slash is for illustration purposes; it does not correspond to the backslash character in C#. A nullreference normally indicates the end of a data structure. Common Programming Error 23.1 Not setting the link in the last node of a list (or other linear data structure) to null is a common logic error. 1 class Node 2 { 3 private int data; 4 private Node next; 5 6 public Node( int d ) 7 { 8 // constructor body 9 } 10 11 public int Data 12 { 13 get 14 { 15 // get body 16 } 17 18 set 19 { 20 // set body 21 } 22 } 23 24 public Node Next 25 { 26 get 27 { 28 // get body 29 } 30 31 set 32 { 33 // set body 34 } 35 } 36 } Fig. 23.1 Fig. 23.FiFig. 23.1g. 23.1Sample self-referential Nodeclass definition. Fig. 23.1
Note: If you are looking for high quality webhost to host and run your jsp application check Vision christian web host services