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; }}
Home » 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; }}
At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.
See our full editorial policy.