Error Message:
Exception in thread \"main\" java.lang.NumberFormatException: For input string: \"Ace of Clubs\"
at java.lang.NumberFormatException.forInputString
int first_value = Integer.parseInt(cards[index]);
while writing the above statement, you are trying to parse "Ace of Clubs" as a number.
you can use the following method to test if any string can be parsed as Integer:
boolean tryParseInt(String value) {
try {
Integer.parseInt(value);
return true;
} catch (NumberFormatException e) {
return false;
}
}
Regarding your question, what is NumberFormatException : It is thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. (ref -http://docs.oracle.com/javase/7/docs/api/java/lang/NumberFormatException.html)