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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:47:58+00:00 2026-05-27T19:47:58+00:00

I am so close to getting this project to work, but I’m stuck on

  • 0

I am so close to getting this project to work, but I’m stuck on one thing that is driving me crazy and I can’t find anything in my research that is working.

What I need to do is declare a new variable each time the for loop passes through the recordset, but I need to use the index value (i) in the variable name.

The line I need help with is Bottles o[i] = new Bottles();

I need to define a new variable each time the for loop passes through again, for example, my variables should end up being o1, o2, o3, etc. I’m getting a syntax error on the [i] right now and I can’t seem to find out how to do this.

Any thoughts on what I’m missing here?

private void getBottles() {
        try {
            m_bottles = new ArrayList<Bottles>();
            for (int i = 0; i < bottleNamesMap.size(); i++) {
                Bottles o[i] = new Bottles();
                o[i].setbottleID(bottleIntMap.get("bottleID" + i));
                o[i].setname_abbr(bottleNamesMap.get("name" + i));
                o[i].setorigin(bottleNamesMap.get("origin" + i));
                o[i].setbottlePicture(bottleNamesMap.get("bottlePicture" + i));
                o[i].setprice_reported(bottleNamesMap.get("price" + i));
                o[i].setdistillery(bottleNamesMap.get("distillery" + i));
                o[i].setagg_score(bottleIntMap.get("aggscore" + i));
                m_bottles.add(o[i]);
                Thread.sleep(2000);
                Log.i("ARRAY", "" + m_bottles.size());
            }
          } catch (Exception e) {
            Log.e("BACKGROUND_PROC", e.getMessage());
          }
          runOnUiThread(returnRes);
      }
  • 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-27T19:47:59+00:00Added an answer on May 27, 2026 at 7:47 pm
     Bottles o[i] = new Bottles();
    

    should be:

      Bottles o = new Bottles();
    

    Then drop the [i]. The new keyword will create a new object each iteration.

                Bottles o = new Bottles();
                o.setbottleID(bottleIntMap.get("bottleID"+i));
                o.setname_abbr(bottleNamesMap.get("name"+i));
                o.setorigin(bottleNamesMap.get("origin"+i));
                o.setbottlePicture(bottleNamesMap.get("bottlePicture"+i));
                o.setprice_reported(bottleNamesMap.get("price"+i));
                o.setdistillery(bottleNamesMap.get("distillery"+i));
                o.setagg_score(bottleIntMap.get("aggscore"+i));
                m_bottles.add(o);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my app is getting force close randomly. And every time error can not be
Connection.close() may throw SqlException , but I have always assumed that it is safe
I know that this is quite subjective, but is it something that I have
I have begun work on a personal project that may end up having some
I Have implemented JSTREE on my project everything work fine but recently I faced
http://www.security.org.sg/code/loadexe.html http://pastebin.com/QFHASx75 I've compiled this but can't get it to work properly, It runs
I note that this has been asked before but I haven't found an answer
We are getting close to releasing our new rails app and so far interest
Hi I am facing a problem in Message dialog, getting Force close my code
I'm getting stack overflow errors when I'm trying to publish() a NetStream after close()ing

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.