64k 超过64k会报错:Exception in thread "main" java.lang.ClassFormatError: ttt (Illegal constant pool type)
我用下面这个程序测试了一下,得到的结果是:17033470 不知道在别人的机器上运行会不会得到别的结果?public class ttt { public static void main (String[] args) { StringBuffer sb = new StringBuffer(17033470); String s = null; try { for (int i = 0; i < Integer.MAX_VALUE; i++) { sb.append(i%10); } } catch (java.lang.OutOfMemoryError ex) { System.out.println("FULL"); } s = sb.toString(); System.out.println(s.length()); s = s + "3"; System.out.println(s.length()); } }
超过64k会报错:Exception in thread "main" java.lang.ClassFormatError: ttt (Illegal constant pool type)
不知道在别人的机器上运行会不会得到别的结果?public class ttt {
public static void main (String[] args) {
StringBuffer sb = new StringBuffer(17033470);
String s = null;
try {
for (int i = 0; i < Integer.MAX_VALUE; i++) {
sb.append(i%10);
}
} catch (java.lang.OutOfMemoryError ex) {
System.out.println("FULL");
}
s = sb.toString();
System.out.println(s.length());
s = s + "3";
System.out.println(s.length());
}
}