public static String
reverseVowels(String s) {
String vowels =
"aeiouAEIOU";
char[] tmp = s.toCharArray();
int i =
0, j = s.length() -
1;
while(i < j) {
while(i < j && vowels.indexOf(tmp[i]) <
0) i++;
while(i < j && vowels.indexOf(tmp[j]) <
0) j--;
if(i < j) {
char tmpChar = tmp[i];
tmp[i] = tmp[j];
tmp[j] = tmpChar;
i++;
j--;
}
}
return new String(tmp);
}
转载请注明原文地址: https://ju.6miu.com/read-1126206.html