I tried to create a Java class to test as below:
public class ModifyArrayList<D> extends ArrayList<D> {
public D getModIndex(int index) {
int validIndex = Math.abs(index) % this.size();
return this.get(validIndex);
}
}
When I call this using the main method I get a warning ‘Raw use of parameterized class‘:
ModifyArrayList testList = new ModifyArrayList();
testList.add(0,1);
testList.add(1,2);
testList.add(2,3);
testList.add(3,4);
System.out.println(testList.getModIndex(1));
System.out.println(testList.getModIndex(-2));
System.out.println(testList.getModIndex(40));
What can I do about this?
I was trying to create class ModifyArrayList
to handle invalid indexes used to retrieve data from ArrayList
class objects. The expected output is generated but I still see the warning.
New contributor
Sandali Ranasinghe is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.