提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用addLast方法向LinkedList添加项
/*来 自 nowjava.com*/ import java.util.LinkedList; public class Main { public static void main(String[] args) { LinkedList<String> officers = new LinkedList<String>(); officers.addFirst("B"); officers.addFirst("M"); officers.addFirst("D"); officers.addFirst("P"); officers.addFirst("L"); for (String s : officers) System.out.println(s); } }