I'm trying to print out an object's instance variable's contents, but I'm stuck on how to do that. Here's my .java file where I ask to fill the array
for (int i = 0; i < friends.length; i++) {
friends[i] = new Datab();
System.out.println("\nFilling object #: " + (i + 1));
Scanner kb = new Scanner(System.in);
System.out.println("Enter First name: ");
first = kb.next();
System.out.println("Enter Last name: ");
last = kb.next();
System.out.println("Enter Cell Number: ");
cell = kb.next();
}
And here's the .java file with the constructor and the toString
protected static String first;
protected static String last;
protected static String cell;
private String what;
public Datab()
{
first = null;
last = null;
cell = null;
}
public Datab(String f, String l, String c)
{
first=f;
last=l;
cell=c;
}
public static String getFirst(Datab [] n)
{
return first;
}
public static String getLast(Datab [] n)
{
return last;
}
public static String getCell(Datab [] n)
{
return cell;
}
public String toString(){
return("");
}
}