char[] word = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
for (int i = 0; i < word.length / 2; i++) {
char temp = word[i];
word[i] = word[word.length - 1 - i];
word[word.length - 1 - i] = temp;
}
for (char x : word) {
System.out.print(x + "\t");
}
数组元素反转
最新推荐文章于 2023-09-13 17:54:29 发布