提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
将数组作为方法参数传递
public class Main { public static void main(String[] args) { int[] num = {7, 8}; /* *来 自 N o w J a v a . c o m - 时 代 Java */ System.out.println("Before swap"); System.out.println("#1: " + num[0]); System.out.println("#2: " + num[1]); // Call the swpa() method passing the num array swap(num); System.out.println("After swap"); System.out.println("#1: " + num[0]);/*时代Java公众号*/ System.out.println("#2: " + num[1]); } // swaps the values if array contains two values. public static void swap (int[] source) { if (source != null && source