Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 913683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:36:01+00:00 2026-05-15T17:36:01+00:00

I need to implement an ArrayList which can hold like person records. I can

  • 0

I need to implement an ArrayList which can hold like person records. I can only do this so far:


CODE


import java.util.*;

class ArrayListDemo {

public static void main(String args[]) {

    ArrayList al = new ArrayList();
    System.out.println("Initial size of al: "
            + al.size());

    al.add("C");
    al.add("A");
    al.add("E");
    al.add("B");
    al.add("D");
    al.add("F");
    al.add(1, "A2");
    System.out.println("Size of al after additions: "
            + al.size());

    System.out.println("Contents of al: " + al);

    al.remove("F");
    al.remove(2);
    System.out.println("Size of al after deletions: "
            + al.size());
    System.out.println("Contents of al: " + al);
}
}

A member of this website told me to do the following, I really dont get how to get about doing that:


You do

ArrayList<Person> myList = new ArrayList<Person>();

and then you can repeatedly

newPerson = new Person("Bruce", "Wayne", 1972, "Gotham City");

myList.add(newPerson);

and you can access folks in the list by doing

int personNumber = 0;

Person retrievedPerson = myList.get(personNumber);

or even

for (Person someone : myList) {
   System.out.println(someone);
}

Any help as to complete a simple program utilizing the above points mentioned by that particular stackoverflow member (ie. answer by Carl Smotricz) would be appreciated.

Thanks alot

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T17:36:02+00:00Added an answer on May 15, 2026 at 5:36 pm

    Go through this

    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package sl4jdemo;
    
    import java.util.ArrayList;
    import java.util.List;
    
    /**
     *
     * @author Administrator
     */
    public class arrayTest {
    
        public static class Person{
            String name;
            String SSL;
            String Street;
            Integer age;
    
            public String getSSL() {
                return SSL;
            }
    
            public void setSSL(String SSL) {
                this.SSL = SSL;
            }
    
            public String getStreet() {
                return Street;
            }
    
            public void setStreet(String Street) {
                this.Street = Street;
            }
    
            public Integer getAge() {
                return age;
            }
    
            public void setAge(Integer age) {
                this.age = age;
            }
    
            public String getName() {
                return name;
            }
    
            public void setName(String name) {
                this.name = name;
            }
    
            public Person(String name, String SSL, String Street, Integer age) {
                this.name = name;
                this.SSL = SSL;
                this.Street = Street;
                this.age = age;
            }
    
        }
        public static void main(String[] args) {
            List<Person> persons = new ArrayList<arrayTest.Person>();
            persons.add(new Person("Bob", "FKJHHS87546", "WALLSTREET", 21));
            persons.add(new Person("Tom", "SEFSDF875463", "WALLSTREET", 25));
            for (Person person : persons) {
                System.out.println("Name : "+person.getName());
                System.out.println("SSL : "+person.getSSL());
                System.out.println("Street : "+person.getStreet());
                System.out.println("Age : "+person.getAge());
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.