我正在尝试获取列表的大小,但出现错误:
Java HotSpot(TM) 64-Bit Server VM warning: Exception java.lang.OutOfMemoryError occurred dispatching signal UNKNOWN to handler- the VM may need to be forcibly terminated
Exception in thread "main"
这是我的代码:
public void wrapText(String text, int width)
{
List<String> items = new LinkedList<String>(Arrays.asList(text.split(" ")));
for(int j = 0; j < items.size(); j++){
items.add(width, "\n");
}
System.out.println(items);
/* this method needs to be improved - it currently does not wrap text */
// System.out.println(text);
}
我在这里做错了什么?
慕工程0101907
临摹微笑
慕慕森
相关分类