JAVA import静态类的方法

public static int getStoredTicketCount() {
int result = 0;
StorageMap s = new StorageMap(Storage.getLocalStorageIfSupported());
String ticketCount = s.get(TICKETCOUNT_KEY);
if (ticketCount != null) {
result = Integer.parseInt(ticketCount);
}
return result;
}

在另一个类中调用该方法,

import  cn.gxpo.repo.widgetset.client.OfflineDataService.getStoredTicketCount;

报错。后改成:

import static cn.gxpo.repo.widgetset.client.OfflineDataService.getStoredTicketCount;

注意加上了static

正常。

posted @ 2018-09-07 14:30  瓦砾  阅读(550)  评论(0编辑  收藏  举报