The problem is that you are specifying an integer literal 4388576018402626
and that number is larger than the maximum integer, 2147483647
.
You are attempting to pass it to a method that takes a long
, so make it a long
literal by appending L
:
System.out.print(prefixMatched(4388576018402626L, 4388));
The JLS specifies this behavior in Section 3.10.1:
An integer literal is of type long if it is suffixed with an ASCII letter L or l (ell); otherwise it is of type int (§4.2.1).
and
It is a compile-time error if a decimal literal of type int is larger than 2147483648 (231), or if the decimal literal 2147483648 appears anywhere other than as the operand of the unary minus operator (§15.15.4).