package Chapter5;public class TestPassByValue {/** Main method */public static void main(String[] args) {// Declare and initialize variablesint num1 = 1;int num2 = 2;System.out.println("Before invoking the swap method, num1 is " +num1 + " and num2 is " + num2);// Invoke the swap method to attempt to swap two variablesswap(num1, num2);System.out.println("After invoking the swap method, num1 is " +num1 + " and num2 is " + num2);}/** Swap two variables */public static void swap(int n1, int n2) {System.out.println("\tInside the swap method");System.out.println("\t\tBefore swapping n1 is " + n1+ " n2 is " + n2);// Swap n1 with n2int temp = n1;n1 = n2;n2 = temp;System.out.println("\t\tAfter swapping n1 is " + n1+ " n2 is " + n2);}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。