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