I’m new to Java (three days spend actually), but I have to write a custom cross-platform editor app as an interface to my database. Everything is running smooth actually, but I’ve got a strange package error. inb4 3 years of Python and AS3 programming.
I’m trying to extend a java.util.ArrayList and got stucked into the add method overriding. Code looks somehow like that:
package myxmleditor;
public class BarsList<EditorXMLObject> extends
java.util.ArrayList<EditorXMLObject> {
@Override
public boolean add(EditorXMLObject element) {
editorGUI.addEditorPane(element); // error here
return super.add(element);
}
public EditorGUIInterface editorGUI = null;
}
BarsList, EditorGUIInterface and EditorXMLObject are within the myxmleditor package. The addEditorPane method is
EditorGUIInterface.addEditorPane(EditorXMLObject element)
NetBeans shows me an error:
method addEditorPane in class myxmleditor.TsukasaXMLEditGUI cannot be applied to given types;
required: **myxmleditor.EditorXMLObject**
found: **EditorXMLObject**
reason: actual argument EditorXMLObject cannot be converted to myxmleditor.EditorXMLObject by method invocation conversion
Your class BarsList is not a template. If you would like to make BarsList a list of EditorXMLObject, simple write:
public class BarsList extends java.util.ArrayList<EditorXMLObject>However if you would like to create another template basing on ArrayList, write:
public class BarsList<T> extends java.util.ArrayList<T>