Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.LinkedTransferQueue; class Name{ private String name; public Name(String name) { this.name = name; } public String toString(){ return "Name = "+ this.name; } } public class LinkedTransferQueueAddExample3 { public static int i=1; public static void main(String[] args) { LinkedTransferQueue
queue = new LinkedTransferQueue
(); Name s1 = new Name("Jack"); Name s2 = new Name("Johnny"); Name s3 = new Name("Angelina"); Name s4 = new Name("Russell"); queue.add(s1); queue.add(s2); queue.add(s3); queue.add(s4); for (Name xyz : queue){ System.out.println(i++ + ". "+xyz); } } }
Output