As in the title, I can't get to work a method in class A that is used in another class B to extend ArrayList. Here's my "mockup" code:
public class Claz{
private String str;
//Constructor
public Claz(String str){
this.str = str;
}
//get method
public String getStr(){
return this.str;
}
}
Here's the ArrayList extension:
import java.util.*;
public class ClazList<Claz> extends ArrayList<Claz>{
//ArrayList extension constructor: the parameter is a array of Claz
public ClazList(Claz[] clazArray){
for(int i = 0; i < clazArray.length; i++){
this.add(clazArray[i]);
}
}
//Print method that doesn't work
public void printClaz(){
for(int i = 0; this.size(); i++){
System.out.println(this.get(i).getStr());
}
}
}
The compiler error is that the getStr() method is not found in Object class, but I don't even understand why it tries to find it there. The exact message is
error: cannot find symbol
Symbol: method getStr()
location: class Object
What am I doing wrong?