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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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;
}
}
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) {
>>Entry(String firstName, String lastName) {
should be
public Entry(String firstName, String lastName) {
public class myRec
{
String firstname, lastName,streetAddress,pos
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("atjen
ArrayList myArrayofRec= new ArrayList();
myArrayofRec.add(newrec);
etc....