Solved

Create a new record

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Fibonacci challenge 11 84
IT Company 5 69
Spring Controller - inheritance in request parameter 3 38
computer science syllabus 3 53
For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 video teaches viewers about errors in exception handling.

744 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

12 Experts available now in Live!

Get 1:1 Help Now