CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: ArrayList

Threaded View

  1. #1
    Join Date
    May 2009
    Posts
    11

    ArrayList

    Hi,

    How can I add this class object to an arraylist so that it can store a list of employee's details. And my main program able to call that function to retrieve the list of data.
    Thanks

    Code:
    public class Employee {
      private String lastName;
    
      private String firstName;
    
      public Employee(String lastName, String firstName) {
        this.lastName = lastName;
        this.firstName = firstName;
      }
     
    public String getLastName() {
        return this.lastName;
      }
    
      public void setLastName(String lastName) {
    
        this.lastName = lastName;
      }
    
      public String getFirstName() {
        return this.firstName;
      }
    
      public void setFirstName(String firstName) {
        this.firstName = firstName;
      }
    
      public Object clone() {
        Employee emp;
        emp = new Employee(this.lastName, this.firstName);
        emp.setSalary(this.salary);
        return emp;
      }
    
    }
    Last edited by part0; August 14th, 2011 at 10:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured