java 常見問題總結

1.No enclosing instance of type GeoLocation is accessible. Must qualify the allocation with an enclosing instance of type GeoLocation (e.g. x.new A() where x is an instance of GeoLocation).app

解決辦法1:this

This error happens because you're trying to create an instance of an inner class service.submit(new ThreadTask(i)); without creating instance of main class..spa

To resolve this issue please create instance of main class first:code

GeoLocation outer = new GeoLocation();

 

Then create instance of class you intended to call, as follows:blog

service.submit(outer.newThreadTask(i));

解決方法2:get

public static class ThreadTask implements Runnable { ... }

 

參考網址:http://stackoverflow.com/questions/9744639/must-qualify-the-allocation-with-an-enclosing-instance-of-type-geolocation?answertab=votes#tab-topit

相關文章
相關標籤/搜索