devxlogo

A Function to Determine Whether a String Can Be Converted to a Number

A Function to Determine Whether a String Can Be Converted to a Number

The following code shows how to determine whether one string is a number:

public static boolean isNumber(String s){  try  {    new Double(s);    return true;  }  catch(Exception ecc)  {    return false;  }}

devx-admin

Share the Post: