public class Test{ int i; int j; public Test(int i,int j){ } public void show(){ System.out.println(i+j); } public static void main(String[] args){ Test hello=new Test(1,24); hello.show(); } }
public Test1(int i,int j){
this.i = i;
this.j = j;
}
刚刚学的,改构造方法里的int i,int j都是形参,要用指针。
public class Test{
int i;
int j;
public Test(int i,int j){
this.i=i;
this.j=j;
}
public void show(){
System.out.println(i+j);
}
public static void main(String[] args){
Test hello=new Test(1,24);
hello.show();
}
}