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.length == 2) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。