包含超过4680个元素的ArrayList返回空白 [英] ArrayList with more than 4680 elements returning blanks

查看:78
本文介绍了包含超过4680个元素的ArrayList返回空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将ArrayList转换为String,然后将其打印出来.这是我的代码:

I'm trying to turn an ArrayList to a String, and then print it. This is my code:

private void toString(ArrayList<Integer> answer) {
        String s = "";
        for(int i = answer.size() - 1; i >= 0; i--){
            s = s+answer.get(i);

        }

        System.out.println(s);
    }

对于较小的ArrayList,它可以正常工作,但是由于某些原因,对于具有4680个以上元素的ArrayList,它返回一堆空格.而且这不是String的问题.我尝试将字符分别打印到屏幕上,甚至将ArrayList写入文本文件.超过4680还是没有.即使是很奇怪,如果我直接将ArrayList打印到屏幕上,也可以正常工作!我尝试增加控制台输出.没有.有人知道发生了什么吗?!?

It works fine for smaller ArrayLists, but for some reason, for ArrayLists with more than 4680 elements, it returns a bunch of blank spaces. And it's NOT a problem with the String. I tried printing the characters individually to the screen, and even writing the ArrayList to a text file. Still nothing over 4680. ALSO, even weirder, if I just print the ArrayList directly to the screen, it works fine! I tried increasing the console output. Nothing. Does anybody have any idea what's happening?!?

推荐答案

已解决. 这确实与 windows下的Java控制台错误中的错误相同.我在Eclipse中将固定宽度设置为400,它可以正常工作.谢谢Michael Petch!

RESOLVED. It was indeed the same bug as in Java console bug under windows. I set the fixed width to 400 in Eclipse and it worked. Thanks Michael Petch!

这篇关于包含超过4680个元素的ArrayList返回空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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