//基本数据类型参数传递。
class Demo
{
public static void main(String[] args)
{
int x = 4;
show(x);
System.out.println("x="+x);
}
public static void show(int x)
{
x = 5;
}
}
//引用数据类型参数传递。
class Demo
{
int x = 3;
public static void main(String[] args)
{
Demo d= new Demo();
d.x = 6;
show(new Demo());//show(d);
System.out.println("d.x="+d.x);
}
public static void show(Demo d)
{
d.x = 9;
}
}
java参数传递
最新推荐文章于 2023-06-03 17:42:30 发布