Phone Book Application

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

Double value = 2.5;

double sum = value + 5.7;

Yes, it works. It is shorthand for

Double value = new Double( 2.5 );

double sum = value.doubleValue() + 5.7;

Phone Book Application

ArrayLists are especially convenient when you want to maintain a list of your own object types. For example say that you want an application that maintains a phone book. Each entry in the phone book contains a name and a number, along with various methods.

class Entry
{
  private String name;
  private String number;

  // constructor
  Entry( String n, String num )
  {
    name = n; number = num;
  }

  // various methods
  . . .
}

Our program will maintain an ArrayList of phone book entries. The user will type in a name and get a phone number.

QUESTION 21:

Suggest some methods that will be useful for Entry.