So I asked a question previously about returning arrays in Java, to which I got an answer, and now my code is updated with a getter, however I keep getting something along the lines of:
Phone@b08deb
as an output, which is not what I want, and if I were to do something like:
return arr[1];
It tells me that Phone cannot be converted to Phone[], and I'm incredibly lost as to how to get simply the number "00000" to be spit out by the compiler from the array (as I do understand that I don't need to initialize the array because it defaults to 0)
Link to question: How do I return an array to another class in Java?
Updated code:
class TheDriverClass
{
public static void main(String[] args)
{
Phone p = new Phone(5);
System.out.println(p);
// Here it's supposed to return the values of an array with size 5,
//so it should print out 00000
}
}
Next I have the class Phone:
class Phone
{
private Phone[] arr; //I'm supposed to keep the array private
public Phone(int theLength){
arr = new Phone[size];
}
public Phone[] getPhone(){
return arr;
}
}