1 public class MyQueue { 2 3 /** 4 *用LinkedList来实现队列Queue先进先出 5 */ 6 private LinkedList list =new LinkedList(); 7 8 public void put(Object o) 9 { 10 list.add(o); 11 } 12 13 public Object get() 14 { 15 return list.removeFirst(); 16 } 17 18 public boolean isEmpty() 19 { 20 return list.isEmpty(); 21 } 22 23 public static void main(String[] args) 24 { 25 MyQueue myqueue=new MyQueue(); 26 myqueue.put("one"); 27 myqueue.put("two"); 28 myqueue.put("three"); 29 30 System.out.println(myqueue.get()); 31 System.out.println(myqueue.get()); 32 System.out.println(myqueue.get()); 33 34 System.out.println(myqueue.isEmpty()); 35 } 36 37 }