A good answer might be:
It will be useful to have an | |
Complete |
class Entry
{
String name;
String number;
// constructor
Entry( String n, String num )
{
name = n; number = num;
}
// methods
public boolean equals( Object other )
{
return name.equals( ((Entry)other).name );
}
public String toString()
{
return "Name: " + name + " Number: " + number;
}
}
|
The toString() method overrides the
toString() method that all objects
have.
Our method returns a more useful string than the
inherited method.
What does the following code write?
Click Here after you have answered the questionEntry ent = new Entry( "Amy", "123-4567"); System.out.println( ent );