Do we have any number of lines limit in a Method
Maximum size of a method in Java 7 and 8
65535 bytes Long// But we should take care of Java coding standards, code should be readable
,like wise limit for variable and methods in java?
Max name length of variable or method in Java
Maximum Method Name Length
NO limit as such// But we should take care of Java coding standards, code should be readable
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 should be fine, should not be an issue
SIZE 100000,
int num[] = new int[100000];
SIZE Integer.MAX_VALUE,
int num[] = new int[Integer.MAX_VALUE];
Exception in thread "main" java.lang.OutOfMemoryError: Requested array size exceeds VM limit
In Java, arrays internally use integers (int not Integer)
for index
, the max size is limited by the max size of integers
. So theoretically it is 2^31-1 = 2147483647
, which is Integer.MAX_VALUE
. But in recent HotSpot JVM it has been observed that the max size of array can be Integer.MAX_VALUE - 5.
Error in eclipse:Too many constants, the constant pool for Tst(this is
class) would exceed 65536 entries
Refer Java “too many constants” JVM error