I have been using vectors in the past and am very familiar with them. I have heard that ArrayLists are faster and more flexible. I am new to using ArrayLists and Java Generics. I am currently using them as follows and receiving a warning about parametrization (Which I thought I did by declaring them <String>
.
ArrayList<String> arrayList = new ArrayList <String> ();
...
//then within a method
arrayList.add(file.getName()); //<-This line triggers the warning.
I have found online that this can be avoided by suppressing warnings in the method, as you can see below. However, this is a work around and I would rather learn how arraylists work and use them properly rather than suppress warnings from using them incorrectly.
@SuppressWarnings("unchecked")
And please, if there is some sort of convention or standards regarding using ArrayLists I would love to learn about those too.
EDIT: The warning I am recieving is the following: Type safety: The method add(Object) belongs to the raw type ArrayList. References to generic type ArrayList should be parameterized