Results 1 to 5 of 5
  1. #1
    kenzo240 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Question String concatenation problem

    if(expandedTag[baseIndex - 1] == 0)
    {
    baseArray[baseIndex] = new String(bufferString.append(temp2).append("SHOULD_B E_COLLAPSED").toString());
    }
    else if(expandedTag[baseIndex - 1] == 1 || expandedTag[baseIndex - 1] == -1)
    {
    baseArray[baseIndex] = bufferString.append(temp2).toString();
    }

    I don't see what could be wrong with the top string, but it destroys the app. The bottom works fine. What am I doing wrong?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default Re: String concatenation problem

    it destroys the app.
    If you get execution errors, please copy the full text and paste them here

  3. #3
    kenzo240 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Default Re: String concatenation problem

    Source code can be found here: Android Tree Bulletin

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: String concatenation problem

    Moved from 'New to Java'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    kenzo240 is offline Member
    Join Date
    Nov 2011
    Posts
    3
    Rep Power
    0

    Post Re: String concatenation problem

    //I have found a solution to this particular problem

    String collapsedString = "SHOULD_BE_COLLAPSED";

    char[] chars = new char[10000];

    for(int x = 0; x < bufferString.length(); x++)
    {
    chars[x] = bufferString.charAt(x);
    }

    for(int x = bufferString.length(); x < temp2.length() + bufferString.length(); x++)
    {
    chars[x] = temp2.charAt(x - bufferString.length());
    }

    for(int x = temp2.length() + bufferString.length(); x < collapsedString.length() + temp2.length() + bufferString.length(); x++)
    {
    chars[x] = collapsedString.charAt(x - bufferString.length() - temp2.length());
    }

    baseArray[baseIndex] = String.copyValueOf(chars).trim();

Similar Threads

  1. String concatenation vs. StringBuilder.
    By stchman in forum New To Java
    Replies: 5
    Last Post: 08-23-2011, 11:17 AM
  2. Concatenation with strings
    By link6790 in forum New To Java
    Replies: 16
    Last Post: 05-05-2011, 07:33 PM
  3. Replies: 4
    Last Post: 08-19-2010, 01:06 AM
  4. Database Column vs String Concatenation
    By varun_33 in forum JDBC
    Replies: 1
    Last Post: 12-11-2007, 04:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •