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

查看:14
本文介绍了包含超过 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);
    }

它适用于较小的 ArrayLists,但由于某种原因,对于超过 4680 个元素的 ArrayLists,它返回一堆空格.这不是字符串的问题.我尝试将字符单独打印到屏幕上,甚至将 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?!?

推荐答案

RESOLVED.这确实与 Windows 下的 Java 控制台错误中的错误相同.我在 Eclipse 中将固定宽度设置为 400 并且它起作用了.感谢迈克尔·佩奇!

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天全站免登陆