How to check whether a string is numeric using Apex in Salesforce?

Example:

String str = '45f6';
if(str.isNumeric()) {
   // Sinces str is not numeric, it never enters into this loop
}


Example:

String str = '456';
if(str.isNumeric()) {
   // Sinces str is numeric, it enters into this loop
}

Cheers!!!

No comments:

Post a Comment