Given a String, is there a way to make sure that it's a valid real number, containing only the digits 0 - 9 and has no more than one decimal point? Would attempting a cast and catching an exception work or is there a better way?
You could use valueOf(), pass the string to it. If it ain't a number that will fit within the wrapper object you're using, it will throw a NumberFormatException. If you wanted, you could use a bunch of if statements or something like that, but I would imagine the best way would be using a try/catch( NumberFormatException e ) block [This message has been edited by jason adam (edited August 16, 2001).]