Solved

Create a new record

Posted on 2004-03-31
6
207 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

719 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