Solved

Create a new record

Posted on 2004-03-31
6
178 Views
Last Modified: 2010-03-31
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

0
Comment
Question by:atjendrasa
  • 3
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 50 total points
ID: 10723278
You mean a list of record?

http://java.sun.com/docs/books/tutorial/java/concepts/

We can't do classwork here btw - only help you with work that you've produced
0
 
LVL 2

Expert Comment

by:Thunder_scream
ID: 10723340
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....

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10723447
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;
      }

}
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10723454
Whoops

>>Entry(String firstName, String lastName) {

should be

public Entry(String firstName, String lastName) {
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to implement Singleton Design Pattern in Java.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now