Reputation: 23
public class temp
{
public int data0;//整数
public int data1;//小数
public int data2;
public int data3;
public long firsttime;
public temp(int type,int data0, int data1, int data2, int data3,
long firsttime) {
super();
this.data0 = data0;
this.data1 = data1;
this.data2 = data2;
this.data3 = data3;
this.firsttime = firsttime;
}
}
public class ShareDate {
public static temp mtemp=null;
public static date mdate=null;
}
the problem is in MainActivity
I did like this
ShareDate.mtemp.date0=20;
then the program was stopped unexpected. I don't know where it's wrong?
Upvotes: 0
Views: 72
Reputation: 1448
You need to initialize before object use.. There is no initialization code..
mtemp=new temp();
And why u use constructor?
If you use ,
ShareDate.mtemp.date0=20; like this ,,
no need a constructor.
Upvotes: 0
Reputation: 42016
where is your initialization code?
mtemp=new temp();
A class's object must be initialized to use its data member/Methods.
Upvotes: 1