Java 101: Datastructures and algorithms in Java, Part 4

Like arrays, linked lists are a fundamental datastructure category upon which more complex datastructures can be based. Unlike a sequence of elements, however, a linked list is a sequence of nodes, where each node is linked to the previous and next node in the sequence. Recall that a node is an object created from a self-referential class, and a self-referential class has at least one field whose reference type is the class name. Nodes in a linked list are linked via a node reference. Here’s an example:


class Employee
{
   private int empno;
   private String name;
   private double salary;
   public Employee next;
   // Other members.
}

In this example, Employee is a self-referential class because its next field has type Employee. This field is an example of a link field because it can store a reference to another object of its class–in this case another Employee object.

To read this article in full, please click here

分類: IT 資訊科技(信息技术), java 1 對 1 私人補習, 熱門新聞,標籤: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , 。這篇內容的永久連結