# Vector add() unchecked?



## MPW (24. Jul 2005)

Hi,

ich hab' ein Programm geschrieben, das um sich zwischen durch ein paar Dinge zu merken Vectoren verwendet.

Ich bekomme jedoch immer Warnings:

```
C:\Programme\Java\Progs\Thinking\Thinking.java:263: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
					schon.addElement(i);
                                                        ^
C:\Programme\Java\Progs\Thinking\Thinking.java:264: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
					schon2.addElement(i);
                                                         ^
C:\Programme\Java\Progs\Thinking\Thinking.java:271: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
						schon.addElement(k);
                                                                ^
C:\Programme\Java\Progs\Thinking\Thinking.java:272: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
						schon2.addElement(i);
                                                                 ^
C:\Programme\Java\Progs\Thinking\Thinking.java:355: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			habSchon.add(comp);
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:453: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
				wörter.addElement(line);
                                                 ^
C:\Programme\Java\Progs\Thinking\Thinking.java:459: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
				newWords.addElement(line);
                                                   ^
C:\Programme\Java\Progs\Thinking\Thinking.java:465: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
				ignore.addElement(line);
                                                 ^
C:\Programme\Java\Progs\Thinking\Thinking.java:528: warning: [unchecked] unchecked call to Vector(java.util.Collection<? extends E>) as a member of the raw type java.util.Vector
			Vector kurz = new Vector(wörter);
                                      ^
C:\Programme\Java\Progs\Thinking\Thinking.java:539: warning: [unchecked] unchecked call to Vector(java.util.Collection<? extends E>) as a member of the raw type java.util.Vector
			Vector kurz = new Vector(wörter);
                                      ^
C:\Programme\Java\Progs\Thinking\Thinking.java:562: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
				zwischen.addElement(line);
                                                   ^
C:\Programme\Java\Progs\Thinking\Thinking.java:610: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[words]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:612: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
				zwischen.add(ki);
                                            ^
C:\Programme\Java\Progs\Thinking\Thinking.java:614: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[words-end]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:615: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[newwords]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:617: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
				zwischen.add(ki);
                                            ^
C:\Programme\Java\Progs\Thinking\Thinking.java:619: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[newwords-end]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:620: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[ignore]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:622: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
				zwischen.add(ki);
                                            ^
C:\Programme\Java\Progs\Thinking\Thinking.java:624: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			zwischen.add("[ignore-end]");
                                    ^
C:\Programme\Java\Progs\Thinking\Thinking.java:676: warning: [unchecked] unchecked call to addElement(E) as a member of the raw type java.util.Vector
			newWords.addElement(nw);
                                           ^
C:\Programme\Java\Progs\Thinking\Thinking.java:719: warning: [unchecked] unchecked call to Vector(java.util.Collection<? extends E>) as a member of the raw type java.util.Vector
			kurz = new Vector(wörter);
                               ^
C:\Programme\Java\Progs\Thinking\Thinking.java:728: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.Vector
			kurz.add(word);
                                ^
23 warnings

Prozess erfolgreich beendet.
```

In der API zu 1.5 habe ich allerdings nix gefunden, weiß jemannd, wie ich das wegkriegen kann, es funktioniert zwar, nervt aber gewaltig:-(

Danke für Tipss....


----------



## Beni (24. Jul 2005)

Dein Quellcode könnte hilfreich sein... 

Besonders wenn er nicht die Form hat:

```
Vector<X> v = new Vector<X>();
X x = new X();
v.add( x );
```


----------



## Sky (24. Jul 2005)

http://java.sun.com/j2se/1.5/pdf/generics-tutorial.pdf


----------



## MPW (25. Jul 2005)

Jo, dann sach' ich mal Danke für den Tipp.
(Es ist halt ungünstig ein J-p. für 1.5 mit 1.4er API zu schreiben;-))


----------



## Sky (25. Jul 2005)

MPW hat gesagt.:
			
		

> Jo, dann sach' ich mal Danke für den Tipp.
> (Es ist halt ungünstig ein J-p. für 1.5 mit 1.4er API zu schreiben;-))


Eigentlich ist es egal, weil's ja nur Warnungen sind... Dein Prog. sollte auch so ohne Probleme laufen.


----------



## MPW (25. Jul 2005)

Ja, aber es nervt, da ich TextPad benutzte und der bei Warnings nicht zurück zum Quelltext springt, außerdem möchte ich mich ja auch "weiterbilden" und 1.5 Code schreiben!


----------

