public static void main(String[] args) {
byte[] a ={10,0,80,68,53};
for(int i=0;i<a.length/2;i++) {
byte temp=a[i];
a[i]=a[a.length-1-i];
a[a.length-1-i]=temp;
}
System.out.print(Arrays.toString(a));
}
颠倒字节数组
最新推荐文章于 2025-12-01 13:49:36 发布
这段Java代码演示了如何使用for循环和临时变量实现数组的反转。通过遍历数组的一半长度,交换首尾元素,实现了数组元素的原地翻转。最后通过Arrays.toString()打印出反转后的数组。
438

被折叠的 条评论
为什么被折叠?



