Simple example demonstration of using queue (java.util.queue) in Java

From , 5 Years ago, written in Java, viewed 196 times.
URL https://pastebin.vip/view/670eca4a
  1. /**
  2.  *
  3.  * @author Zang XT
  4.  */  
  5. import java.util.Queue;  
  6. import java.util.LinkedList;  
  7. public class TestQueue {  
  8.     public static void main(String[] args) {  
  9.         Queue<String> queue = new LinkedList<String>();  
  10.         queue.offer("Hello");  
  11.         queue.offer("World!");  
  12.         queue.offer("你好!");  
  13.         System.out.println(queue.size());  
  14.         String str;  
  15.         while((str=queue.poll())!=null){  
  16.             System.out.print(str);  
  17.         }  
  18.         System.out.println();  
  19.         System.out.println(queue.size());  
  20.     }  
  21. }  
  22. //java/6424

Reply to "Simple example demonstration of using queue (java.util.queue) in Java"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website