I have an array of strings:
void populateStringArray()
{
toppings = new String[20];
toppings[0] = "Cheese12";
toppings[1] = "Pepperoni1234";
toppings[2] = "Black Olives1";
// ...
And I want to return the one with least numeric characters.
Can some one suggest the logic to achieve this?
You can loop over characters and use
Character.isDigit()to count digits in the string.Output: