Re: Vector (was Re: Change character in string)
Andreas Leitgeb wrote:
Lew <lew@lewscanon.com> wrote:
RedGrittyBrick wrote:
One thing you can do with the former but not
the latter is compile without warnings.
For the claim of only Vector throwing the warning, ...
I don't see that they made that claim.
Oh really? (Or are you just splitting hairs now, about eclipse -
not Vector - being the one writing/throwing/issuing warnings?)
My original two contestants *both* had that omission. (I just checked
back.) And in that case, eclipse really should have warned about both.
RGB: Would you care to re-check and elaborate on your experiment?
It's a waste of effort but...
-----------------------------------8<-----------------------------------
package org.redgrittybrick.test;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
public class TestCollection {
List<Foo> lf1 = new Vector();
List<Foo> lf2 = new ArrayList();
List<Foo> lf3 = new Vector<Foo>();
List<Foo> lf4 = new ArrayList<Foo>();
class Foo {}
}
-----------------------------------8<-----------------------------------
ArrayList is a raw type. References to generic type ArrayList<E>
should be parameterized TestCollection.java line 9
Type safety: The expression of type ArrayList needs unchecked conversion
to conform to List<TestCollection.Foo> TestCollection.java line 9
Type safety: The expression of type Vector needs unchecked conversion to
conform to List<TestCollection.Foo> TestCollection.java line 8
Vector is a raw type. References to generic type Vector<E> should be
parameterized TestCollection.java line 8
------------------------------------------------------------------------
There, as anticipated, this exercise sheds no light on the real issue.
I still don't see why I should not prefer ArrayList over Vector when
several Sun documents refer to ArrayList replacing Vector and Vector
being "historical".
I see nothing wrong in promoting the use of ArrayList instead of Vector.
In the same way that I see nothing wrong in having the recent Javadocs
promote StringBuilder instead of StringBuffer.
I haven't grasped why you and Peter seem to think otherwise.
your emendation of their post to change its meaning notwithstanding.
I'm not sure, what emendations in the relevant lines 3 and 5 of my sscce
you think I could have meant to change any meaning?
Changing Foo to Test? Changing the varname from lf to lt and a digit?
PS: Is RGB plural?
RGB is singular. It may be that Lew is choosing a gender-neutral
possesive pronoun.
--
RGB