Я полностью понимаю, как работает наследование и ключевое слово super, но не в этом роде.
public class Stack<T> implements StackADT<T> {
/**
* The array into which the objects of the stack are stored.
*/
private T[] data;
/**
* The number of objects in this stack.
*/
private int size;
/**
* The default capacity of this stack.
*/
private static final int MAX_SIZE = 100;
/**
* Constructs a new Stack with capacity for 100 objects
*/
public Stack(){
this.data = (T[]) new Object[MAX_SIZE];
this.size = 0;
}
public Stack(int size){
this.data = (T[]) new Object[size];
this.size = 0;
}
public int getSize(){
return this.size;
}
Как бы я назвал этот конструктор в подклассе Stack?Мне нужно изменить емкость на 52 в подклассе, называемом discardPile.
Примеры, которые я делал ранее, были такими:
private double salary = 1500;
public Faculty(String n, String i, String o, double s) {
super(n, i, o); //where names = n, i = ID, and o = office were inheriented from their parents' constructors which assigned name = n; and etc.
salary = s; //unique instance variable
}
Это гораздо более простой пример, поскольку нетнесколько конструкторов для работы и вещи назначаются на буквы.
Я просто хочу понять, как вызывать метод в этих случаях.