if I want to convert a string into an int in java do you know if there is a way for me to detect overflow? by that I mean the string literal actually represents a value whic
You don't need to do anything.
As the Javadoc for Integer.parseInt(str, radix)
states, a NumberFormatException
is thrown if the value represented by the String is not representable as an int
value; i.e. if its magnitude is too big. This is described as a separate case from the case where str
is badly formatted, so it is clear (to me) that this is what is meant. (And you can confirm this by reading the source code.)