mirror of https://github.com/Black-Gold/Learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
456 B
30 lines
456 B
public class Jb21_DataTransmit
|
|
{
|
|
//基本数据类型参数传递
|
|
public static void main(String[] args)
|
|
{
|
|
int x = 1;
|
|
show(x);
|
|
System.out.println(x); //输出1
|
|
}
|
|
public static void show(int x)
|
|
{
|
|
x = 2;
|
|
}
|
|
}
|
|
//引用数据类型参数传递
|
|
class Demo
|
|
{
|
|
int x = 1;
|
|
public static void main(String[] args)
|
|
{
|
|
Demo data = new Demo();
|
|
data.x = 3;
|
|
show(data);
|
|
System.out.println(data.x); //输出为2
|
|
}
|
|
public static void show(Demo data)
|
|
{
|
|
data.x = 2;
|
|
}
|
|
} |