java System.out.println()奇怪的行为长字符串 [英] java System.out.println() strange behavior long string

查看:166
本文介绍了java System.out.println()奇怪的行为长字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以解释一下为什么这段代码不打印数字?

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

      String text = new String("SomeString");
      for (int i=0; i<1500; i++) {
                text = text.concat(i+"");
      }
      System.out.println(text);

结果

      SomeString

如果我将运行次数降低到1000,它为什么?
如果我不仅添加了一个数字而且还添加了一个字符,那么它可以正常工作。

If I lower the number of runs to 1000 it works, why?! And also if I add not only a number but also a character, it works.

Ok New Update:

感谢代码示例。我尝试过它们,除了我发现的是,控制台

实际上显示数字,但只有在fontcolor白色。但是String
SomeString 的第一部分是黑色的。

Thanks for the code examples. I tried them all but what I found out is, that the console
actually display the numbers but only in fontcolor white. But the first part of the String SomeString is black.

我使用jdk1.7.0_06!

I use jdk1.7.0_06 !

推荐答案

这是eclipse错误。固定宽度控制台修复输出。

This is eclipse bug. Fixed width console fixes the output.

这篇关于java System.out.println()奇怪的行为长字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆