java System.out.println() strange behavior long string

前端 未结 5 1333
再見小時候
再見小時候 2021-01-12 17:31

Can somebody explain me why this code does not print the numbers?

      String text = new String("SomeString");
      for (int i=0; i<1500; i++)          


        
5条回答
  •  鱼传尺愫
    2021-01-12 18:23

    String.concat() accepts a String parameter.

    If you add "a number and a character" you are adding a string because the + operator understands you are chaining String and numeric data.

    Anyway code runs fine to me, numbers appended till 1499 as expected.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题