提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
删除LinkedList的第一个和最后一个元素
import java.util.LinkedList; /* 来自 *时代Java - N o w J a v a . c o m*/ public class Main { public static void main(String[] args) { LinkedList lList = new LinkedList(); lList.add("1"); lList.add("2"); lList.add("3"); lList.add("4"); lList.add("5"); System.out.println("LinkedList contains : " + lList); Object object = lList.removeFirst(); System.out.println(object + " has been removed from the first index of LinkedList"); System.out.println("LinkedList now contains : " + lList); object = lList.removeLast(); System.out.println(object +