Java 11, repeat error message [231 - 1] times
Number of times to repeat is Integer.MAX_VALUE / 5 - because "fatal" is 5 chars.
throw new Error("fatal".repeat(Integer.MAX_VALUE/5));
String's Maximum length in Java is Integer.MAX_VALUE i.e. == 231 - 1, or less, it depends on server max memory size and other conditions otherwise it produces OutOfMemoryError.
You can return something like this. It is not the error itself, but the error message:
for(int i=0;i<Integer.MAX_VALUE;i++){
String m="fatal"+i;
out.println(m.repeat(Integer.MAX_VALUE/m.length()-1));
}
You can throw some
Errorwith the certain message, for example:throw new Error("fatal".repeat(Integer.MAX_VALUE/5));Number of times to
repeatisInteger.MAX_VALUE/ 5 - because"fatal"is 5 chars.You can return something like this. It is not the error itself, but the error message:
for(int i=0;i<Integer.MAX_VALUE;i++){ String m="fatal"+i; out.println(m.repeat(Integer.MAX_VALUE/m.length()-1)); }