如何在 Java 方法中按引用傳遞引數?
按引用傳遞引數是指使用一個帶引數的方法呼叫。透過此方法,引數值被傳遞給引數。
示例
public class SwappingExample {
public static void swapFunction(int a, int b) {
int c = a+b;
System.out.println("Sum of the given numbers is ::"+c);
}
public static void main(String[] args) {
int a = 30;
int b = 45;
swapFunction(a, b);
}
}
輸出
Sum of the given numbers is ::75
廣告
資料結構
網路
關係資料庫管理系統 (RDBMS)
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP