java - Implementation of an abstract class -
i have abstract class want inherit from:
public abstract class myfirstclass<k extends comparable<k>, v> implements iterable<mysecondclass<k, v>> { // abstract methods }
i'm not sure how write declaration of class extends abstract class. thought like:
public class myfirstclassimpl<k, v> extends myfirstclass<object, object> { @override public iterator iterator() { // code } // implementation of abstract methods myfirstclass }
but dosen't seem work way , have trouble finding explanation kind of problem.
if sub-class should generic, should have same generic parameter declaration base class :
public class myfirstclassimpl<k extends comparable<k>, v> extends myfirstclass<k,v> { @override public iterator<mysecondclass<k, v>> iterator() { // code } }
otherwise, sub-class shouldn't have generic type parameters @ :
public class myfirstclassimpl extends myfirstclass<someclassthatimplementscomparable, object> { @override public iterator<mysecondclass<someclassthatimplementscomparable,object>> iterator() { // code } // implementation of abstract methods myfirstclass }
Comments
Post a Comment