Link to home
Start Free TrialLog in
Avatar of atjendrasa
atjendrasa

asked on

Create a new record

Hi,
i'm new to java, so can anyone please help me?
i'm making an address book program and it has
first name
last name
street adress
post code
phone number

can some one please tell me how to create a record of list?

thanks very much

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Thunder_scream
Thunder_scream

something to get you started....but you have to do the rest your self

public class  myRec
{
    String firstname, lastName,streetAddress,postCode;
    int phoneNum;
  //or String phoneNum; depending on the format

   String getfirstName(){
    return firstName;
   }
   
   void setfirstName(String fn){
    firstName=fn;
   }
    // and other get and set methods
}

myRec newrec= new myRec();
newrec.setfirstName("atjendrasa")

ArrayList myArrayofRec= new ArrayList();
myArrayofRec.add(newrec);

etc....

That should follow conventions thus:


public class Entry {
      private String firstName;
      private String lastName;
      
      Entry(String firstName, String lastName) {
            // other fields needed too
            this.firstName = firstName;
            this.lastName = lastName;
      }

      public void setFirstName(String firstName) {
        this.firstName = firstName;
      }

      public String getFirstName() {
        return firstName;
      }

      public void setLastName(String lastName) {
        this.lastName = lastName;
      }

      public String getLastName() {
        return lastName;
      }

}
Whoops

>>Entry(String firstName, String lastName) {

should be

public Entry(String firstName, String lastName) {