1. 程式人生 > >Java 需要註意的寫法

Java 需要註意的寫法

clas cep str ppr 靜態 override ktr tom java

public class InfoLoadPresenterImpl implements InfoLoadPresenter {

private InfoLoadView ilv;
private Handler handler;

@SuppressLint("HandlerLeak")
@Override
public void infoLoad() {
ilv.infoLoadStart();

handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what)
{
case 1:
ilv.infoLoadSuccess((Customer) msg.obj);
break;
}

}
};

new Thread(new Runnable() {
@Override
public void run() {
String str;
try {
... ...
} catch (Exception e) {
e.printStackTrace();
}

Message message = new Message();

Gson gson = App.getGson();
Customer customer = gson.fromJson(body.toString(),Customer.class);

message.what = 1;
message.obj = customer;

handler.sendMessage(message);

}
}).start();

}

}

//需要理解 代碼區 靜態變量區 堆區 棧區 和 java引用才能理解的代碼

Java 需要註意的寫法