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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:22:25+00:00 2026-06-13T02:22:25+00:00

In a activy I have written code that works correctly. But now I have

  • 0

In a activy I have written code that works correctly.

But now I have added a method to this activity with the following code:

    private void obtenerDatosReuniones(){

    try {

        int j=0;

        String aux = jsonReuniones.getString("nombres");

        String aux2 = null;

        aux2 = aux.replace("[", "");

        aux2= aux2.replace("]", "");

        String [] campos = aux2.split(",");

        while(j<campos.length){

            nombres_reuniones.add(campos[j]);

        }

the type of nombres_reunones is ArrayList

When I run the application appears out the following error on line nombres_reuniones.add (campos [j]):

What am I doing wrong?

Thanks!

  • 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-13T02:22:28+00:00Added an answer on June 13, 2026 at 2:22 am

    Look at your loop:

    while(j<campos.length){
        nombres_reuniones.add(campos[j]);
    }
    

    How do you anticipate that ever finishing? You don’t modify j. Given that you don’t make any change to j after declaring it and assigning it a value of 0 right at the start, it would be much clearer as:

    for (int j = 0; j < campos.length; j++) {
        nombres_reuniones.add(campos[j]);
    }
    

    Or better:

    for (String item : campos) {
        nombres_reuniones.add(item);
    }
    

    Or even simpler:

    nombres_reunions.addAll(Arrays.asList(campos));
    

    Additionally, your earlier code can be simpler. Look at this:

    String aux2 = null;
    aux2 = aux.replace("[", "");
    aux2= aux2.replace("]", "");
    

    Why bother assigning aux2 an initial value of null which you then immediately overwrite? Additionally, you can easily chain the method calls. It would be neater as:

    String aux2 = aux.replace("[", "").replace("]", "");
    

    And in fact, you can just chain the whole of the string manipulation together from start to finish:

    String[] campos = jsonReuniones.getString("nombres")
                                   .replace("[", "")
                                   .replace("]", "")
                                   .split(",");
    nombres_reunions.addAll(Arrays.asList(campos));
    

    (I’d stop there, rather than inlining even that expression…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been assigned a project with a lot of poorly written code that
I have written the following code to edit the User Profiles for MOSS 2007.
I have written some code that stores values inside a array of arrays. I
Actually I am trying to do jquery tabs. I have written a code that
I have written a jquery script here But there is problem in the $(this).toggleClass(active).next();
I have written the following code: $(document).ready(function () { $(#rade_img_map_1335199662212).hover(function () { $(li#rs1).addClass(active); //Add
I have written a function that creates a barplot. I would like to save
I have written some code which produces simple animations based on cycling through a
When I run a single-threaded program that i have written on my quad core
My code is written in Delphi 7, but I don't think it plays a

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.