Home > Java > javaTutorial > body text

Detailed explanation and example code of java LinkedList class

高洛峰
Release: 2017-02-03 17:20:45
Original
1661 people have browsed it

java Detailed explanation of LinkedList class

Unique functions of LinkedList

A: Add function

public void addFirst(Object e);
 
 public void addLast(Object e);
Copy after login

B :Special function

public Object getFirst();
public Object getLast();
Copy after login

C:Delete function

public Object removeFirst();
 public Object removeLast();
Copy after login

Example code:

import java.util.LinkedList;
  
/*
 * LinkedList的特有功能
 *
 * A:添加功能
 * public void addFirst(Object e);
 * public void addLast(Object e);
 *
 * B:特有功能
 * public Object getFirst();
 * public Object getLast();
 *
 * C:删除功能
 * public Object removeFirst();
 * public Object removeLast();
 * */
  
public class IntegerDemo {
  public static void main(String[] args) {
    // TODO Auto-generated method stub
  
    LinkedList link = new LinkedList();
  
    link.add("hello");
    link.add("world");
    link.add("java");
  
    link.addFirst("javaee");
    link.addLast("android");
  
    System.out.println("link:" + link);
  }
}
Copy after login

Thank you for reading, I hope it can help everyone, thank you everyone for your support of this site!

Please pay attention to the PHP Chinese website for more detailed explanations and example code related articles on the Java LinkedList class!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!