java逆数组如何print-凯发k8官方网
/** 来自 nowjava.com**/
//package com.nowjava;
public class main {
public static void main(string[] argv) throws exception {
object[] arr = new string[] { "1", "abc", "level", null,
"nowjava.com", "asdf 123" };
system.out.println(java.util.arrays.tostring(conversearray(arr)));
}
public static object[] conversearray(object[] arr) {
object para = null;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;//来自 nowjava - 时 代 java
}
public static int[] conversearray(int[] arr) {
int para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;
}
public static char[] conversearray(char[] arr) {
char para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;
}
public static byte[] conversearray(byte[] arr) {
byte para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;
}
public static short[] conversearray(short[] arr) {
short para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;
}
public static long[] conversearray(long[] arr) {
long para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = para;
}
return arr;
}
public static float[] conversearray(float[] arr) {
float para;
for (int i = 0; i <= arr.length / 2; i ) {
para = arr[i];
/**代码未完, 请加载全部代码(nowjava.com).**/
总结
以上是凯发k8官方网为你收集整理的java逆数组如何print_java 逆数组的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: java try finally con
- 下一篇: .net 访问mysql链接池_c# –