Given the following class:
public class Customer {
protected String firstName;
protected String lastName;
protected String ID;
protected float amountSpent;
// Contructor
// Accessors and mutators
}
public class Gold extends Customer {
protected discount;
// overloaded contructor
// Accessors and mutator
}
and the following code
Customer[][] arr = new Customer[2][1];
Customer[] preferredArr = new Gold[3];
Customer[] regularArr = new Customer[3];
preferredArr[0] = new Gold("John", "Doe", "1234", 45, .12)
regularArr[0] = new Customer("Caroline", "Merritt", "5678", 60)
arr[0] = preferredArr;
arr[1] = regularArr;
How would I access John's information using preferredArr[0].getFirstName() if it is inside of the arr array. Also I can't use ArrayList as specified by my professor. Thanks for the help!
arr[0][0].getFirstName()but you have to be sure thatpreferedArrwill stay at index 0 when launching your program.