我有一个字符串数组:
void populateStringArray()
{
toppings = new String[20];
toppings[0] = "Cheese12";
toppings[1] = "Pepperoni1234";
toppings[2] = "Black Olives1";
// ...
我想返回数字字符最少的那个。
有人可以提出实现这一目标的逻辑吗?
最佳答案
如果使用 Guava是一个选项,你可以这样做:
int digitChars = CharMatcher.DIGIT.countIn(yourString)
关于java - 验证具有最少数字字符数的数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13125217/