0

I tried to append a long String (length of 3000) with java StringBuilder and found out that the appended result is not what I expected.

A.append(B) should be AB

A.append(LongString) becomes A________________(empty spaces)

Any idea?

My code: http://pastebin.com/5CPmHFeS

5
  • 4
    I tried your code, it works as expected. Commented Jul 19, 2011 at 8:03
  • Which version of Java are you using. It worked fine for me on Java 6 update 26. Commented Jul 19, 2011 at 8:04
  • It works just fine, tested with Ideone: ideone.com/zgzi0 Commented Jul 19, 2011 at 8:05
  • 1
    seems like a bug in the Eclipse console that display 404040 as space. They look fine if I copy and paste into notepad. Interesting. Commented Jul 19, 2011 at 8:13
  • Eclipse has a few bug with rendering very long lines (well past 1000 characters, at least). They can lead to ugly rendering errors or (as in your case) simply to empty lines. Commented Jul 19, 2011 at 8:54

2 Answers 2

1

What did you get as output? I got:

sb-320 :404040....
sb-4320:404040....

Truncated for readability, but its correct. I think you may have counted the digits incorrectly. Double check?

Sign up to request clarification or add additional context in comments.

Comments

0

There isn't any problem, that I see.

It works properly : http://www.ideone.com/z8Lxu

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.