我们在方法中是否有任何行数限制,例如 java 中变量和方法的明智限制? 当我将 100000 个整数分配给一个 int 数组时,我也遇到了编译错误,是否有相同的限制?
eclipse报错:常量太多,Tst(this is class)的常量池将超过65536个
最佳答案
Do we have any number of lines limit in a Method
Maximum size of a method in Java 7 and 8
65535 bytes Long//但是我们应该注意Java编码标准,代码应该是可读的
,like wise limit for variable and methods in java?
Max name length of variable or method in Java Maximum Method Name Length
没有限制//但是我们应该注意Java编码标准,代码应该是可读的
And also I was getting compilation error when I was Assigning 100000 ints to one int array, is there any limit for the same?
100000 应该没问题,应该不是问题
尺寸 100000,
int num[] = new int[100000];
SIZE Integer.MAX_VALUE,
int num[] = new int[Integer.MAX_VALUE];
线程“main”中的异常 java.lang.OutOfMemoryError:请求的数组大小超出 VM 限制
在 Java 中,数组在内部使用整数 (int not Integer)
作为 index
,最大大小受整数的最大大小限制
.所以理论上是2^31-1 = 2147483647
,也就是Integer.MAX_VALUE
。 但在最近的 HotSpot JVM 中,观察到数组的最大大小可以是 Integer.MAX_VALUE - 5。
Error in eclipse:Too many constants, the constant pool for Tst(this is class) would exceed 65536 entries
关于java - java类中可以写多少个变量,多少个方法,java方法中可以写多少行代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34153814/