import java.util.List;
import java.util.Queue;
import java.util.LinkedList;
import java.util.ArrayList;
public class queue2List
{
public static void main(String args[])
{
try{
//Creating queue
Queue queue1=new LinkedList();
//Adding some elements into queue
queue1.add("One");
queue1.add("Two");
queue1.add("Three");
//Converting queue into list
List list1=new ArrayList(queue1);
System.out.println(list1);
}
catch(Exception e){
e.printStackTrace();
}
}
}
import java.util.Queue;
import java.util.LinkedList;
import java.util.ArrayList;
public class queue2List
{
public static void main(String args[])
{
try{
//Creating queue
Queue queue1=new LinkedList();
//Adding some elements into queue
queue1.add("One");
queue1.add("Two");
queue1.add("Three");
//Converting queue into list
List list1=new ArrayList(queue1);
System.out.println(list1);
}
catch(Exception e){
e.printStackTrace();
}
}
}
Comments