Author |
Message |
gsquare567
|
Posted: Sat Dec 02, 2006 10:59 pm Post subject: Weird xlint error with my linkedlist adding method |
|
|
check this:
code: |
GalacticWar.java:975: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
|
where getSprites() returns a LinkedList of type AnimatedSprite, and bullets[] is an array of animatedsprite. what could be the problem? ps, this is 28x plus another error... read here:
code: |
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\Asteroids\classes>javac
-Xlint GalacticWar.java
GalacticWar.java:157: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(ship);
^
GalacticWar.java:555: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(ship);
^
GalacticWar.java:599: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(asteroid);
^
GalacticWar.java:691: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(asteroid);
^
GalacticWar.java:708: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(expl);
^
GalacticWar.java:725: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(expl);
^
GalacticWar.java:792: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:799: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:806: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:813: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:820: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:827: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(powerup);
^
GalacticWar.java:920: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:926: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:930: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[1]);
^
GalacticWar.java:936: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:939: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[2]);
^
GalacticWar.java:943: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[2]);
^
GalacticWar.java:949: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:953: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[1]);
^
GalacticWar.java:957: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[2]);
^
GalacticWar.java:961: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[3]);
^
GalacticWar.java:967: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:971: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:975: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:979: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:983: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:987: warning: [unchecked] unchecked call to add(E) as a member
of the raw type java.util.LinkedList
getSprites().add(bullets[0]);
^
GalacticWar.java:8: warning: [serial] serializable class GalacticWar has no defi
nition of serialVersionUID
public class GalacticWar extends Game
^
29 warnings
|
|
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
wtd
|
Posted: Sat Dec 02, 2006 11:51 pm Post subject: (No subject) |
|
|
Of you're using Java 1.5 and collections, you'll need to be familiar with generics. |
|
|
|
|
 |
gsquare567
|
Posted: Sat Dec 02, 2006 11:57 pm Post subject: (No subject) |
|
|
thanks for the help... now can anyone tell me why these are coming up? |
|
|
|
|
 |
OneOffDriveByPoster
|
Posted: Sun Dec 03, 2006 12:29 am Post subject: (No subject) |
|
|
gsquare567 wrote: thanks for the help... now can anyone tell me why these are coming up?
Check your method signature for getSprites(). wtd is right, get used to generics if you are using Java 1.5. |
|
|
|
|
 |
wtd
|
Posted: Sun Dec 03, 2006 9:34 am Post subject: (No subject) |
|
|
We know of what we speak.
code: | import java.util.ArrayList;
public class Foo {
public static void main(String[] args) {
ArrayList arr = new ArrayList();
int i = 5;
arr.add(i);
}
} |
code: | $ javac -Xlint:unchecked Foo.java
Foo.java:8: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
arr.add(i);
^
1 warning |
code: | import java.util.ArrayList;
public class Foo {
public static void main(String[] args) {
ArrayList<Integer> arr = new ArrayList<Integer>();
int i = 5;
arr.add(i);
}
} |
code: | $ javac -Xlint:unchecked Foo.java
$ |
|
|
|
|
|
 |
gsquare567
|
Posted: Sun Dec 03, 2006 2:34 pm Post subject: (No subject) |
|
|
thanks, but it still doesn't work... heres how i declare the LinkedList:
code: |
private LinkedList<AnimatedSprite> sprites;
sprites = new LinkedList<AnimatedSprite>();
|
and heres how i call it:
code: |
public LinkedList getSprites()
{
return sprites;
}
|
i still get the same message, and can you also look at the very last error, something about serialVersionUID? |
|
|
|
|
 |
OneOffDriveByPoster
|
|
|
|
 |
gsquare567
|
Posted: Sun Dec 03, 2006 6:32 pm Post subject: (No subject) |
|
|
OH NO WAY MAN U R GOD! public LinkedList<AnimatedSprite> getSprites()... your a genious! |
|
|
|
|
 |
Sponsor Sponsor

|
|
 |
gsquare567
|
Posted: Sun Dec 03, 2006 6:56 pm Post subject: (No subject) |
|
|
umm hmm... got rid of the "recompile with -Xlint", but now wen i run the internet file, the applet wont work. says "Loading Java Applet Failed"... i did everything required to run an applet, so why isnt it working? |
|
|
|
|
 |
gsquare567
|
Posted: Mon Dec 04, 2006 1:19 pm Post subject: (No subject) |
|
|
any1? |
|
|
|
|
 |
wtd
|
Posted: Mon Dec 04, 2006 1:22 pm Post subject: (No subject) |
|
|
Which browser are you using? |
|
|
|
|
 |
gsquare567
|
Posted: Mon Dec 04, 2006 6:37 pm Post subject: (No subject) |
|
|
firefox, but it worked b4 for 2 other games. i even copied the htm file for the other two and just renamed it + the "code = " parameter |
|
|
|
|
 |
gsquare567
|
Posted: Mon Dec 04, 2006 10:07 pm Post subject: (No subject) |
|
|
heres another problem, might be connected... i cant make a jar file. heres the error message:
code: |
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\Asteroids\src\Version 3>
jar cvfm GalacticWar3.jar manifest.txt *.*
java.io.IOException: invalid header field
at java.util.jar.Attributes.read(Attributes.java:389)
at java.util.jar.Manifest.read(Manifest.java:167)
at java.util.jar.Manifest.<init>(Manifest.java:52)
at sun.tools.jar.Main.run(Main.java:123)
at sun.tools.jar.Main.main(Main.java:903)
|
ps, i include a manifest called manifest.txt plus all the classes needed. the manifest is 3 lines, Main-Class: GalacticWar + 2 blank lines  |
|
|
|
|
 |
Aziz

|
Posted: Tue Dec 05, 2006 9:10 am Post subject: (No subject) |
|
|
using generics would cause that problem, try and step back a few steps in your code (ie. undo a bit, then add in the <> bit). Also, make sure your browser has an up-to-date JRE plug-in installed. The latest is 6 (or 1.6) but that's a prerelease, so 5 (update 9) should be fine |
|
|
|
|
 |
gsquare567
|
Posted: Tue Dec 05, 2006 3:49 pm Post subject: (No subject) |
|
|
i based my entire game on the LinkedList which is where i store the sprites or objects on the screen... so i'll try downloading the latest plugin and update, i'll get back to you to tell you if it still doesnt work. |
|
|
|
|
 |
|