I am getteing an error as LinkedList does not take parameters
LinkedList <Integer>queue = new LinkedList<Integer>(); ///////////////////////////////////////below is the code
import java.util.*;
public class ListQueueDemo { public static void main(String args[]) { int numbers[]={34, 22,10,60,30}; List <Integer>list = new ArrayList<Integer>(); try{ for(int i=0; i<5; i++){ list.add(numbers[i]); } System.out.println("the List is: "); System.out.println(list); LinkedList <Integer>queue = new LinkedList<Integer>(); for(int i=0; i<5; i++){ queue.addFirst(numbers[i]); } System.out.println("The Oueue is: "); System.out.println(queue); queue.removeLast(); System.out.println("After removing last element the queue is: "+ queue);
} catch(Exception e){} } }
Hope i get my answer fast
thank u
Regards,<br /> <br />karthikeyan<br /> <br />Life is Beautiful..<br />Enjoy every Moment
Laxman Guru
Greenhorn
Joined: Feb 26, 2008
Posts: 17
posted
0
Your code works fine for me.what error messages are you getting?can you post it?
Laxman
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35248
7
posted
0
catch(Exception e){}
That's generally not such a good idea. You should at least print out a message that an exception occurred.
Sounds more like you're using Java 1.4 compatibility. I've only seen this error when copying code from a Java 5 project to a Java 1.4 project in Eclipse.