课程: Java Algorithms

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Using the built-in linked list data structure in Java

Using the built-in linked list data structure in Java - Java教程

课程: Java Algorithms

Using the built-in linked list data structure in Java

- [Instructor] With an understanding of the LinkedList data structure, we can begin to work with LinkedLists in Java. In fact, we can use the built-in LinkedList type defined in the util package. We'll import java.util and the LinkedList class. To create a LinkedList, we'll write LinkedList and this will contain strings, so we'll put String in the arrow brackets. The LinkedList type is generic and it can hold many different types of data, including custom object data. All we have to do is specify it upon the list creation. We could specify integer, double or custom type but for this example, we're using strings. Let's add some data to the LinkedList. We can add data at the front or the back of the link using addFirst or addLast. We also have the option to add data before or after specific nodes in the list. Let's use add and add a few strings to the list. These will be appended to the back of the list. Now that we have some data, we can look at some of the other built-in operations…

内容