作者: 陈科宇 时间: 2013-2-3 16:01
class Student {
int age;
String name;
public Student(int age,String name)
{
this.age=age;
this.name=name;
}
}
public class Demo {
// 基本数据类型参数传递
public static void changeJiBen(int x) {
x = 520;
}
//引用数据类型参数传递
public static void changeYinYong(Student s) {
s.age=101;
}
public static void main(String[] args) {
int x = 250;
Student s=new Student(23,"Keyee");
changeJiBen(x);
changeYinYong(s);
System.out.println("x=" + x);
System.out.println("s.age=" + s.age);