我有这样的课
public class StockCodes
{
public static boolean loaded = false;
public static long lastUpdate = 0;
private static long freq = 1000 * 60 * 60 * 24;
public static HashMap<String, Stock> stockMap = new HashMap<String, Stock>();
public static ArrayList<Stock> getCodes()
{
long now = System.currentTimeMillis();
if ((StockCodes.loaded) && ((now - StockCodes.lastUpdate) < freq))
{
System.out.println(StockCodes.loaded);
return stockList;
}
else
{
HttpFetcher fetcher = new HttpFetcher();
....
log.info("Load " + stockList.size() + " Stocks");
StockCodes.loaded = true;
StockCodes.lastUpdate = now;
return stockList;
}
}
public static void main(String[] args)
{
StockCodes.getCodes();
}
}
当我运行 java 应用程序时,它输出“true”。告诉我们股票代码已加载。但是当我调试java应用程序时,它进入了else。我不明白为什么它以这种方式运行,尤其是为什么它在我第一次运行应用程序时输出“真”。谁能帮帮我,谢谢~