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

  • SEARCH
  • Home
  • 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 8223699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:48:06+00:00 2026-06-07T14:48:06+00:00

So currently, I have an ArrayList that looks something like: [ [id, type, name,

  • 0

So currently, I have an ArrayList that looks something like:

[ [id, type, name, $], [id, type, name, $], [id, type, name, $], [id, type, name, $]....]

Now say if i want to compare index 0 with 1, or maybe I want to add another value after the comma:

[id, type, name, $, YOLO]

How would I go about doing this? thanks!

Edit: here something:

I am reading data from Excel:

    for (int i = first; i <= last; i++) {
        Row row = sheet.getRow(i);
        Cell id = row.getCell(0);
        Cell type = row.getCell(1);
        Cell name = row.getCell(2);
        Cell $ = row.getCell(3);

    List temp = new ArrayList();
    temp.add(id);
    temp.add(type);
    temp.add(name);
    temp.add($);
  sData.add(temp);

}

and then when you print sData, it shows exactly how I said earlier.

  • 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-06-07T14:48:10+00:00Added an answer on June 7, 2026 at 2:48 pm

    An ArrayList in Java is a dynamic structure to hold a collection of objects.

    In your case I suspect that you have an Object with attributes id, type, name and $ and you store them in the ArrayList using .add(Object) method.

    What you want is to add another attribute to your Object and use the same method to add that Object to your ArrayList.

    The thing you say about comparing the index…. (i suppose you mean the id variable of each object). Well that is also easy (suppose you implement the apropriate methods in your object – lets say for the variable id you should have a method setId and getId … etc):

    if(arrayList.get(0).getId == .... ){
        //do something
    } 
    

    UPDATE

    public class MyExcelRowObject {
    
        private String id;
        private String type;
        private String name;
        private String $;
    
        public MyExcelRowObject(){
            super();
        }
    
        public MyExcelRowObject(String id, String type, String name, String $) {
            this.id = id;
            this.type = type;
            this.name = name;
            this.$ = $;
        }
    
        public String getId() {
            return id;
        }
    
        public void setId(String id) {
            this.id = id;
        }
    
    
        public String getType() {
            return type;
        }
    
        public void setType(String type) {
            this.type = type;
        }
    
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
    
        public String get$() {
            return $;
        }
    
        public void set$(String $) {
            this.$ = $;
        }
    
    }
    

    And this is the manipulation of the Object

        //this is your Object's holder
        ArrayList<MyExcelRowObject> myList = new ArrayList<MyExcelRowObject> ();
    
        //here you manipulate your rows and add them to your MyExcelRowObject objects
        for (int i = first; i <= last; i++) {
            MyExcelRowObject tmpObj = new MyExcelRowObject();
            Row row = sheet.getRow(i);
            tmpObj.setId(row.getCell(0));
            tmpObj.setType(row.getCell(1));
            tmpObj.setName(row.getCell(2));
            tmpObj.set$(row.getCell(3));
    
            myList.add(tmpObj);
        }
    
        //here is how you manipulate your List objects
        if(myList.get(0).getId().equals(myList.get(1).getId())){
            //the  ids of first and second row are the same
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an arraylist containing classes in C#. The arraylist is filled like
I'm currently writing a program that needs to compare each file in an ArrayList
I have a xml file that looks like this <a> <bb> <c date=20110706 time=1:20
Currently have a drop down menu that is activated on a hover (from display:none
Currently have password protection on my main and sub directories, however I'd like to
I currently have a XSLT 2.0 Stylesheet that I am trying to remove empty
I currently have one project that currently contains multiple packages. These packages make up
I currently have a form with inputs and name attributes. I'm able to get
I currently have a deployed app (fortworth.herokuapp.com) that I am attempting to sort movies
I currently have a MySQL table like: id | friend 1 | 2 1

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.