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 8931119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:02:29+00:00 2026-06-15T09:02:29+00:00

I have 2 array lists. i iterate through list1 and store the data that

  • 0

I have 2 array lists. i iterate through list1 and store the data that matches the seat_no to the index of list2.

list1 contains:

|seat_no | id     |
===================
| 1      | 001    |
| 2      | 002    |
| 3      | 003    | 
| 4      | 004    |
| 7      | 005    |
| 10     | 006    |
| 11     | 007    |

list2 contains:

|index   | id     | seat_no |
=============================
| 1      | 001    | 1       |
| 2      | 002    | 2       |
| 3      | 003    | 3       |
| 4      | 004    | 4       |
| 5      |"blank" |"blank"  |
| 6      |"blank" |"blank"  |
| 7      | 005    | 7       |
| 8      |"blank" |"blank"  |
| 9      |"blank" |"blank"  |
| 10     | 006    | 10      |
| 11     | 007    | 11      |

what list2 should contain:
where list2 must have a limit of 15

|index   | id     | seat_no |
=============================
| 1      | 001    | 1       |
| 2      | 002    | 2       |
| 3      | 003    | 3       |
| 4      | 004    | 4       |
| 5      |"blank" |"blank"  |
| 6      |"blank" |"blank"  |
| 7      | 005    | 7       |
| 8      |"blank" |"blank"  |
| 9      |"blank" |"blank"  |
| 10     | 006    | 10      |
| 11     | 007    | 11      |
| 12     |"blank" |"blank"  |
| 13     |"blank" |"blank"  |
| 14     |"blank" |"blank"  |
| 15     |"blank" |"blank"  |

Here’s my code so far… pls help me.. i plan to use array but i don’t know if its applicable to my codes now..

ViewGridObject.java

public class ViewGridObject 
{
    public String stud_id, seat_no;

    public ViewGridObject(String stud_id, String seat_no)
    {
        this.stud_id = stud_id;
        this.seat_no = seat_no;
    }
}

main.java

ArrayList<HashMap<String, String>> to_take = new ArrayList<HashMap<String, String>>();

        try 
        {
            JSONObject jArray = new JSONObject(result);

            JSONArray stud_info = jArray.getJSONArray("stud_info");

            ca_list = new ArrayList<ViewGridObject>();

            for (int i = 0; i < stud_info.length(); i++) 
            {
                HashMap<String, String> map = new HashMap<String, String>();
                JSONObject e = stud_info.getJSONObject(i);

                map.put("id", String.valueOf(i));
                map.put("stud_id", e.getString("student_id"));
                map.put("seat_no", e.getString("seat_no"));
                to_take.add(map);

                ca_list.add(new ViewGridObject(e.getString("student_id"), e.getString("seat_no")));


            }

            List<ViewGridObject> list2 = new ArrayList<ViewGridObject>();
            int i1 = 0;
            for (ViewGridObject o : ca_list) {
                for (i1++; !o.seat_no.equals(i1 + ""); i1++) {
                    list2.add(new ViewGridObject(null, 0, i1 + ""));
                }
                list2.add(o);
            }
  • 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-15T09:02:31+00:00Added an answer on June 15, 2026 at 9:02 am
    List<ViewGridObject> list2 = new ArrayList<ViewGridObject>();
    
    for(int i=0;i<50;i++) {
        try {
                list2.add(list1.get(i));
        } catch(Exception rr) {
                list2.add(new ViewGridObject("blank","blank");
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListView in main.xml where android:entries=@array/list1 and I'd like to update that
I have been trying to serialize a list that contains arrays and lists. I
I have an array list: private ArrayList<PerfStatBean> statFilterResults; I want to iterate through it
I have an array of lists of numbers, e.g.: [0] (0.01, 0.01, 0.02, 0.04,
I have an array list named newSymptomList which contains a list of Symptom id's
Say you need to have a list/array of integers which you need iterate frequently,
I am using a for loop to iterate through a list of arrays that
This is probably a simple question, but how do you iterate through an array,
I have a table of data that I'm trying to standardize. The data entered
I have a model that looks like this: class Pdf extends \lithium\data\Model { protected

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.