I\'m porting a small snippet of PHP code to java right now, and I was relying on the function is_numeric($x) to determine if $x is a number or not. Th
is_numeric($x)
$x
Just use if((x instanceof Number) //if checking for parsable number also || (x instanceof String && x.matches("((-|\+)?[0-9]+(\.[0-9]+)?)+")) ){ ... } //---All numeric types including BigDecimal extend Number
Just use if((x instanceof Number)
//if checking for parsable number also
|| (x instanceof String && x.matches("((-|\+)?[0-9]+(\.[0-9]+)?)+"))
){ ... } //---All numeric types including BigDecimal extend Number