Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Java (https://www.askmehelpdesk.com/forumdisplay.php?f=440)
-   -   Java Question of passing an Array into a method (https://www.askmehelpdesk.com/showthread.php?t=706031)

  • Sep 30, 2012, 07:28 PM
    oneoderja
    Java Question of passing an Array into a method
    Define an integer array ‘arr’ with size 2 in the main method and initialize the two elements in ‘arr’ to be 1 and 2
    Write a method ‘swap’ and pass the ‘arr’ into the method, swap two elements of the ‘arr’ in the method
    Print out all elements in ‘arr’ in the main method
    System.out.print(arr[0] + ‘ ‘ + arr[1]);
    Swap(arr);
    System.out.print(arr[0] + ‘ ‘ + arr[1]);

  • All times are GMT -7. The time now is 04:37 PM.