I have a GUI that I use as a calculator. When I enter in anything other than numbers, it throws a NumberFormatExc eption, as intended. But when I enter in a number such as "23423f" the program seems to think I'm entering a float and doesn't throw an exception, because of the f at the end, even though all other letters throw an exception.
Currently, all I'm doing is putting the input section into a try catch block, where I parse it into a double, and having it catch a NumberFormatExc eption if there is one (because only numbers can be parsed into doubles), and another catch block to throw an IllegalArgument Exception from an if statement for any input less than 0.
That's just a guess, but I don't know why else only f at the end wouldn't throw an exception.
Currently, all I'm doing is putting the input section into a try catch block, where I parse it into a double, and having it catch a NumberFormatExc eption if there is one (because only numbers can be parsed into doubles), and another catch block to throw an IllegalArgument Exception from an if statement for any input less than 0.
That's just a guess, but I don't know why else only f at the end wouldn't throw an exception.
Comment