Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ResvCpAry
- {
- /*int型数组翻转类*/
- public static int[] resvAryInt (int [] aryInt)
- {
- int aryIntLen;
- aryIntLen = aryInt.length;
- int[] aryIntResved = new int[aryIntLen];
- for (int i = 0; i < aryIntLen; i++)
- aryIntResved [i] = aryInt [aryIntLen - i - 1];
- return aryIntResved;
- }
- /*测试翻转类*/
- public static void main(String args[])
- {
- int[] testAryInt = {0, 1, 2, 3, 4, 5};
- int[] resvAry = resvAryInt(testAryInt);
- int len = testAryInt.length;
- String out1 = "原数组: ";
- String out2 = "翻转数组:";
- for (int i = 0; i < len; i++)
- {
- out1 += testAryInt[i];
- out2 += resvAry [i];
- }
- System.out.println(out1);
- System.out.print(out2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement