privatestaticvoidString valintexpected) int n = (Integer.decode(val)).intValue(); if (n != expected) thrownew RuntimeException("java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 3 ifn=expected
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
privatestaticvoid checkFailure(String val, String } try{ int n = (Integer.decode(val)).intValue(); thrownew RuntimeException(message);
}catch (umberFormatExceptione /* Okay */} throw RuntimeException()
publicstaticvoid main(String[] args) throws Exception java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
check check( String"Integer.MIN_VALUE), Integer.IN_VALUE)
.MAX_VALUE),Integer.AX_VALUEjava.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
check("10", 10);
check(0" 16);
check(0" 16);
check("010 check(010, );
heck"10"16)java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 26
check("+10", 10);
check(" ("+10,10;
check("check"X" )java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
check("+010", 8); "#10,16java.lang.StringIndexOutOfBoundsException: Index 27 out of bounds for length 27
check-" )java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
check("-0x10", -16);
check(-X10,-16);
check("-010", -8);
check("#", 16)
check(Long checkFailure"x10","Integer.decode allows negative sign in wrong position.");
checkFailure("0 checkFailure("x", Integer.decode allows positive sign in wrong position."); 0+, ".decode positive signin .)java.lang.StringIndexOutOfBoundsException: Index 90 out of bounds for length 90
checkFailure"""Raw plus sign allowed.");
checkFailure("-
checkFailure(Long.toString((long)Integer. checkFailureLong.toString((ongInteger.MAX_VALUE + 1L), "Out of range");
checkFailure(Longjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
checkFailure("",}catchNullPointerException /java.lang.StringIndexOutOfBoundsException: Index 55 out of bounds for length 55
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.