Search code examples
javastringstringbuffer

StringBuffer toString() not printing anything


This code snippet doesn't print anything in jdk 1.8. Why so ?

 StringBuffer sb = new StringBuffer();
    for (int i = 0; i < 10000; i++)
        sb.append(String.valueOf(i));
    System.out.println(sb.toString());

Solution

  • Since you printing a very long string, the issue here is with Eclipse. Even after removing the limit of console it is not printing anything (going to raise bug on eclipse forum soon).

    However the other IDE's like NetBeans and IntelliJ printing perfect.