NumberFormatException in Java and how to prevent it

NumberFormatException occurs in Java when we are trying to convert string into some numeric type but string is not in the correct format. It usually occurs when we parse string to integer, double, long etc datatypes but string is not present in correct format. Let us see an example code : Output Since ‘123a’ cannot … Read more