Ok. I making a GUI application this time. All it does is handle some data so I decided to use a LinkedList.
I imported java.util.*;
I had the following...
LinkedList stack = new LinkedList();
ok no prob. But when compiling it warns about unsafe operations but still works fine if ignore it.
So to fix that warning I did this...
LinkedList<String> stack = new LinkedList<String>();
but now it won't even recognize it.
In eclipse for "LinkedList" it says "The type LinkedList is not generic; it cannot be parameterized with arguments <String>" and for "<String>" it says "Syntax error, parameterized types are only available if source level is 5.0" and so can't compile. It gives "Exception in thread "main" java.lang.NoClassDefFoundError: Assign3"
Can anyone help me out on this.
need java help again - collections
- Firestorm ZERO
- Member
- Posts: 59
- Joined: Sat Nov 25, 2000 12:00 am
- Location: Toronto, Ontario CANADA
- Firestorm ZERO
- Member
- Posts: 59
- Joined: Sat Nov 25, 2000 12:00 am
- Location: Toronto, Ontario CANADA
some are worse is the point. i guess it depends on what the application is being written for. if it's for school or work, get rid of them. if it's for your own personal use, it doesn't matter. another thing is that wasn't a warning in 1.4.x -- they just added that w/ the 5.0 jdk, so if you're writing 1.4 code, it really shouldn't be showing up..if you're using 5.x functionality (enums, the new string stuff, etc), then that's a different story
- Firestorm ZERO
- Member
- Posts: 59
- Joined: Sat Nov 25, 2000 12:00 am
- Location: Toronto, Ontario CANADA
I understand that, but you can set eclipse to enforce functionality based on Java versions.
Right click your project, go to Properties, Click on Java Compiler, now look under JDK Compliance. Make sure it's set to 5.0. Now try parameterizing the type of the LinkedList.
LinkedList<String> li = new LinkedList<String>();
Compiles just fine for me w/ out warnings w/ the Compliance level set to 5.0. I hope this helps.
Right click your project, go to Properties, Click on Java Compiler, now look under JDK Compliance. Make sure it's set to 5.0. Now try parameterizing the type of the LinkedList.
LinkedList<String> li = new LinkedList<String>();
Compiles just fine for me w/ out warnings w/ the Compliance level set to 5.0. I hope this helps.
- Firestorm ZERO
- Member
- Posts: 59
- Joined: Sat Nov 25, 2000 12:00 am
- Location: Toronto, Ontario CANADA