提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
交换数字Java
/*N o w J a v a . c o m - 时 代 Java 提供*/ public class Main { public static void main(String[] args) { int num1 = 10; int num2 = 20; System.out.println("Before Swapping"); System.out.println("Value of num1 is :" + num1); System.out.println("Value of num2 is :" +num2); //swap the value swap(num1, num2); } /* 来自 时代Java - nowjava.com*/ private static void swap(int num1, int num2) { int temp = num1; num1 = num2; num2 = temp; System.out.println("After Swapping");