代码求解释- public class ParamTest{
- public static void main(String[] args) {
- //Test1
- double percent =10;
- tipleValue(percent);
- //Test2
- Empoyee harry= new Empoyee("Harry",5000);
- tripeSalary(harry);
- Empoyee a =new Empoyee("Alice", 7000);
- Empoyee b = new Empoyee("bod", 8000);
- swap(a,b);
- }
- private static void swap(Empoyee a, Empoyee b) {//不能交换执行?????
- Empoyee temp=a;
- a=b;
- b=temp;
-
-
- }
- private static void tripeSalary(Empoyee x) {//能改变 salary的值??
- x.raiseSalary(200);
-
- }
- private static void tipleValue(double percent) {//不能改变percent 的值???
- percent=3*percent;
-
- }
- }
- class Empoyee{
- private String name;
- private double salary;
- public Empoyee(String aname, double s) {
- name=aname;
- salary=s;
- }
- public String getName(){
- return name;
- }
- public double getSalary(){
- return salary;
- }
- public void raiseSalary(double byPercent){
- double raise=salary*byPercent/100;
- salary+=raise;
- }
-
- }
复制代码 |