有没有办法将数组中的字符串转换为小写?
所以说我有一个类似的数组:
String mainArray[] = {"Dog", "caT", "ElepHANT", "Hungry", "LION"}
// So mainArray[0] = "Dog" mainArray[1] = "caT" etc.
// So i get:
mainArray[] = {"dog", "cat", "elephant", "hungry", "lion"}
是否有函数或方法迭代数组并将每个字符串转换为小写?
答案 0 :(得分:-3)
以下是答案: -
String mainArray[] = {"Dog", "caT", "ElepHANT", "Hungry", "LION"};
StringBuilder stringBuilder=new StringBuilder();
for (String aMainArray : mainArray) {
String lowerData = aMainArray.toLowerCase() + "\t";
stringBuilder.append(lowerData);
}
System.out.print(stringBuilder);