these's something strangly i found that is when String
length in java exceeding a value, then it shown odd.
there is my test code
public static void main(String[] args) {
int length = 4096;
char[] chars = new char[length];
for (char c : chars) {
c = 'c';
}
String str = new String(chars);
System.out.println(str.length());
System.out.println(str);
}
when i run above code on my computer, i get 4096 space character output from console.
then i change the length variable to 4095, this time output is correct, 4095 c
character.
but on another computer, the output does not correct unless the length variable less than 2900.
i just can't figure out why?
EDIT
i think i figured out what's going on, i try to run it again in command window, even though the length value is big enough , it's print correct.
so it seemed like some limit about eclipse's console.
but i checked my eclipse console buffer size, its 800000