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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:51:17+00:00 2026-06-08T16:51:17+00:00

This is the piece of code. List<BDDObject> childlist = savingObject.getChildren(TherapyAreaReference); if (childlist.size() > 1)

  • 0

This is the piece of code.

List<BDDObject> childlist = savingObject.getChildren("TherapyAreaReference");

if (childlist.size() > 1) {
  for (int i = 0; i < childlist.size() - 1; i++) {
    String newMedcondRefChild = ((String) childlist
            .get(i)
            .getValue( IDDConstants.IDD_THERAPY_AREA_REF_VALUE))
            .toLowerCase()
            .trim()
            .concat(((String) childlist
            .get(i)
            .getValue(IDDConstants.IDD_THERAPY_AREA_REF_TYPE_NAME)) 
            .toLowerCase().trim());
  }
}

IDDConstants has public static final strings defined in it. As StringBuffer is more effective, how can it be incorporated for the concat operations?

  • 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-08T16:51:19+00:00Added an answer on June 8, 2026 at 4:51 pm

    I’m guessing that the intention is to generate a list of ‘reports’, one for each BDDObject record found. Based on that idea, your code should look more like this:

    public List<String> getReport(List<BDDObject> records) {
    List<String> reports = new ArrayList<String>(record.size());
        for (BDDObject record:records) {
        String newMedcondRefChild = String.valueOf(record.getValue( IDDConstants.IDD_THERAPY_AREA_REF_VALUE))
                .toLowerCase()
                .trim() + String.valueOf(record.getValue(IDDConstants.IDD_THERAPY_AREA_REF_TYPE_NAME))) 
                .toLowerCase().trim());
        reports.add(newMedcondRefChild);
        }
        return reports;
    }
    

    Regarding the question on whether toString() would be helpful, the only place where I see it fitting, would be on the BDDObject itself. It would look something like this:

    class BDDObject {
    ...
        @Override
        public String toString() {
            return String.valueOf(getValue(IDDConstants.IDD_THERAPY_AREA_REF_VALUE)).toLowerCase().trim() + 
                String.valueOf(getValue(IDDConstants.IDD_THERAPY_AREA_REF_TYPE_NAME)).toLowerCase().trim());
    }
    

    In which case, the function to create the report becomes trivial:

    public List<String> getReport(List<BDDObject> records) {
    List<String> reports = new ArrayList<String>(record.size());
        for (BDDObject record:records) {
            reports.add(record.toString());
        }
        return reports;
    }
    

    In case that what you want is a looooong string with all the values concatenated to it, you can use StringBuilder, like this:

    public String getReport(List<BDDObject> records) {
    StringBuilder sb = new StringBuilder();
        for (BDDObject record:records) {
            sb.append(String.valueOf(record.getValue( IDDConstants.IDD_THERAPY_AREA_REF_VALUE))
                .toLowerCase()
                .trim());
            sb.append(String.valueOf(record.getValue(IDDConstants.IDD_THERAPY_AREA_REF_TYPE_NAME)) 
                .toLowerCase().trim()));
    
        }
        return sb.toString();
    }
    

    This will return all the records appended after each other. I doubt its readability, but you I hope you get the idea. StringBuilder is helpful when you need to build a string iteratively (like in the previous example). StringBuilder should not be used to replace single String operations like : String a = b.get() + c.get(); given that the compiler implicitly creates a StringBuilder in these cases and therefore there’s no actual performance improvement to be achieved.

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

Sidebar

Related Questions

I have this piece of code: string x = textBox1.Text; string[] list = x.Split(';');
I have this piece of code List<Class<? extends SubApplication>> appClasses = new ArrayList<Class<? extends
This piece of code is supposed to go through a list and preform some
Given this piece of code : public static void writeFile(File file,List buffer)throws IOException{ File
I have this small piece of code that basically takes a list and runs
I'm executing the following piece of code: ActivityManager actvityManager = (ActivityManager) this.getSystemService(ACTIVITY_SERVICE); List<RunningTaskInfo> procInfos
I have the following piece of code. This is written for getting the list
I have written this piece of code public class Test{ public static void main(String[]
I have this piece of code and it's causing NullPointerException private List<Player> playerList; private
I am currently studying this piece of code. It's a linked list implemented in

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.