java - How to throw exception for statment? -
Hello! I want to throw exceptions for the line.
barcode no = long.partial long (jTextField1.getText ()) I did it in a way / P>
not barcode = long.parseong (jTextField1.getText ()) New numberFormat exceptions throw ("Enter numbers only"); But in this manner the compiler error says ";"
">
If the text is not in the correct format then message , then you have to catch the exception and throw a new one: Try {barcode = long.parsling (jTextField1 gettext ());} hold (NumberFormatException e) {new number FormatAccertation ("Enter numbers only");} I Do not suggest that you send a user-view message Trying to use the exception message as sh - though they are more appropriate for logging from appearing to the end user.
Comments
Post a Comment