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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:40:58+00:00 2026-05-24T09:40:58+00:00

i have a simple doubt in android programming. I am not familiar with java

  • 0

i have a simple doubt in android programming. I am not familiar with java coding.so it might be a simple problem.

In the first two lines I am retrieving an array, which i passed from another activity to this activity…Then i am creating an array list . I am creating an object in the 4th line. Now comes the problem …
I have to run a for loop to get the url value, which i have to pass it in the BaseFeedParser class. but i cant use the 4th line, i.e creating the object inside the loop because it will create a new object each time… which should not happen … how can i fix this probelm?

                    Intent myintent = getIntent();
        String[] ActiveURL = myintent.getStringArrayExtra("URL");

        List<String> titles = new ArrayList<String>();
        BaseFeedParser parser = new BaseFeedParser(url);

        // fetching all active URLs
        for (int i = 0; i < ActiveURL.length + 1; i++) {
            url = ActiveURL[i];
            messages.addAll(parser.parse());
        }

        // now getting the titles out of the messages for display
        for (Message msg : messages) {
            titles.add(msg.getTitle());
        }

Thanks in advance …

  • 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-24T09:40:59+00:00Added an answer on May 24, 2026 at 9:40 am

    There are some problems in your java code :

        Intent myintent = getIntent();
        //variables are named in camel case, starting with a lower case letter
        String[] activeURL = myintent.getStringArrayExtra("URL");
    
        List<String> titles = new ArrayList<String>();
        //we will use parser later, see below
        //BaseFeedParser parser = new BaseFeedParser(url);
    
        // fetching all active URLs
        //it's very easy to loop through a table in java / C / C++
        //learn the pattern, it's the simplest, you got confused with the final index
        for (int i = 0; i < activeURL.length ; i++) {
            //here you don't change the former object url was referencing,
            //you are saying that you give the name url to another object in the array
            //it doesn't create any new item, change giving them a name to use them
            url = activeURL[i];
            //create a new parser for each url, except if they can be recycled
            //i.e they have a property setUrl
            messages.addAll( new BaseFeedParser(url).parse());
        }
    
        // now getting the titles out of the messages for display
        for (Message msg : messages) {
            titles.add(msg.getTitle());
        }
    

    Indeed, you could even shorten the whole thing by

        Intent myintent = getIntent();
        String[] activeURL = myintent.getStringArrayExtra("URL");
        List<String> titles = new ArrayList<String>();
    
        // fetching all active URLs
        //use a for each loop
        for ( String url : activeURL ) {
            //loop through messages parsed from feed to add titles
            for (Message msg : new BaseFeedParser(url).parse() ) {
               titles.add(msg.getTitle());
            }
        }
    

    if you don’t need the List of Message you called messages.

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

Sidebar

Related Questions

I have simple problem as I am not much familiar with Java GUI. I
Ok, i have simple scenario: have two pages: login and welcome pages. im using
In general, is it a best practice to have simple POJO Java classes implement
I have a simple setter method for a property and null is not appropriate
please help me with a simple PHP doubt. I have a simple form: <
I've been programming with Java for Android quite some while now. Since performance is
I have some doubts over how Enumerators work, and LINQ. Consider these two simple
I have created a simple Twisted based TCP server and Android client. I have
I have a simple query doubt. Question Table qid question 1 ques1 2 ques2
I have a doubt concerning the Entity Framework in .NET. I have a simple

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.