From charlesreid1

(Created page with "To check if a String in Java is numeric, build a simple utility function: <pre> public static boolean isNumeric(String str) { try { double d = Double.parseDou...")
 
No edit summary
Line 15: Line 15:
}
}
</pre>
</pre>
=Flags=
{{CSFlag}}

Revision as of 17:41, 13 June 2017

To check if a String in Java is numeric, build a simple utility function:

public static boolean isNumeric(String str)  
{  
  try  
  {  
    double d = Double.parseDouble(str);  
  }  
  catch(NumberFormatException nfe)  
  {  
    return false;  
  }  
  return true;  
}


Flags





See also: