package com.boda.xy;
public class PassByValue {
public static void change(int num) {
num = num * 2;
System.out.println(num); // 输出:200
}
public static void change(Employee emp) {
// 在方法体中修改员工的工资
emp.setSalary(8000);
System.out.println(emp.getSalary()); // 输出:8000
}
public static void main(String[] args) {
int number = 100;
change(number);
System.out.println(number); // 输出:100
Employee employee = new Employee();
employee.setSalary(5000);
change(employee);
// 方法调用后输出员工的工资
System.out.println(employee.getSalary()); // 输出:8000
}
}