Solved

Create a new record

Posted on 2004-03-31
6
203 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 106
SequenceInputStream example 3 37
Eclipse for Java EE development 2 68
glassfish admin console 1 47
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses

734 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