package test; import java.util.*; import javax.security.auth.kerberos.KerberosKey; import java.io.*; import java.math.BigInteger; public class Main { private static final String space_operator = " "; public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(new BufferedInputStream(System.in)); PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out)); LinkedList link = new LinkedList(); //从开头添加 link.addFirst("sdsd "); link.addFirst("23 "); link.addFirst("45 "); //从尾部添加 link.addLast("99 "); link.addFirst("sdsd "); System.out.println(link); for(Iterator it = link.iterator(); it.hasNext();) { System.out.println(it.next()); } System.out.println(); while(!link.isEmpty()) { System.out.println(link.remove()); } } }