next up previous
Next: 1.4.2 Constructors Up: 1.4 Java Class Definitions Previous: 1.4 Java Class Definitions

  
1.4.1 Defining Classes to Represent Compound Data

We have finally introduced enough Java mechanics to define the data required to represent the department directory entries described in Section 1.2.5. Recall that a directory entry is a object with the following fields and methods:

Fields:
    String name;
    String address;
    String phone;
	
Methods:
    String getName();
    String getAddress();
    String getPhone();
In Java, we define this new form of data as the class
class Entry {
  String name;	
  String address;
  String phone;

  String getName() { return name; }
  String getAddress() { return address; }
  String getPhone() { return phone; }
}



Corky Cartwright
2000-01-07