如何在 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