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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:47:31+00:00 2026-06-09T14:47:31+00:00

I am using strings for concat operations. I want to use stringbuffer/stringbuilder as they

  • 0

I am using strings for concat operations. I want to use stringbuffer/stringbuilder as they are more effective.

Original code:

List<BDDObject> childlist; 
String newassetReferenceType = new String();

for (int i = 0; i < childlist.size(); i++)
{
newassetReferenceType = ((String) childlist.get(i).getValue(IDDConstants.IDD_COMPOUND_ASSET_REF_TYPE_NAME)).toLowerCase().trim().concat(((String) childlist.get(i).getValue(
IDDConstants.IDD_COMPOUND_ASSET_REF_VALUE)).trim());

}

SO I tried to change it as
Changed code:

List<BDDObject> childlist; 
StringBuffer newassetReferenceType = new StringBuffer();

for (int i = 0; i < childlist.size(); i++)
{
newassetReferenceType = ((String) childlist.get(i).getValue(IDDConstants.IDD_COMPOUND_ASSET_REF_TYPE_NAME)).toLowerCase().trim().append(((String) childlist.get(i).getValue(
IDDConstants.IDD_COMPOUND_ASSET_REF_VALUE)).trim());

}

Now there is an error that trim() and toLowerCase() methods can not be used. But I have to use them anyhow. Can somebody tell me how to get the advantage of trim() and toLowerCase()and still use StringBuffer.

  • 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-09T14:47:32+00:00Added an answer on June 9, 2026 at 2:47 pm

    Your solution should work just fine. I think your parentheses are just a little bit off. You should perform trim() and toLowerCase() operations on the strings before appending them to your StringBuffer.

    I rewrote your code to illustrate the concept, using proper parenthesization. Feel free to reformat it and put it in one line, but I think this way it is more readable and less prone to mistakes.

    List<BDDObject> childlist; 
    StringBuffer newassetReferenceType = new StringBuffer();
    
    for (int i = 0; i < childlist.size(); i++)
    {
        var value1 = (String) childlist.get(i).getValue(IDDConstants.IDD_COMPOUND_ASSET_REF_TYPE_NAME);
        var value2 = (String) childlist.get(i).getValue(IDDConstants.IDD_COMPOUND_ASSET_REF_VALUE);
    
        newassetReferenceType.Append(value1.toLowerCase().trim())
        .append(value2.trim());
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using StringBuffer in Java to concat strings together, like so: StringBuffer str =
Possible Duplicate: Concat all strings inside a List<string> using LINQ I am using C#
I am writing some code to type strings using the Robot class. Everything is
I have a code here that generates XML for Engineer list using linq. My
With this code for a very basic logger: lock (string.Concat(LogWritter_, this.FileName)) { using (var
I am using the MSDN Dynamic linq to sql package. It allows using strings
Ok, I understand that using strings that have special characters is an encoding issue.
Using magic strings in C# really unsettles me, so I'm thinking of using the
I'm generating HTML dynamically using Delphi strings (Delphi XE). What is the correct way
In GWT one typically loads i18n strings using a interface like this: public interface

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.