trying to inherit array adapter class it gives me an error when not defining a constructor in subclass....why should I define a constructor
public class WordAdapter extends ArrayAdapter<word> {
public WordAdapter(Activity context, ArrayList<word> word) {
super(context,0, word);
}
Question : ...why should I define a constructor?
Answer: Since ArrayAdapter class has no default constructor, we need to define a constructor that matches one of the six constructors in the superclass.
You can read more about this here:
Not every constructor is being inherited by a subclass. ArrayAdapter has no default constructor and that is the reason you need to define a constructor which should be called.
There are lots of articles which describe the exact behavior of constructors in subclasses.
When is it obligatory to define constructors in subclasses?
Answer: In this case if no default constructor is present in the superclass.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.