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).

解决办法1:

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..

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

GeoLocation outer = new GeoLocation();

 

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

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

解决方法2:

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-top

 

posted @ 2013-12-13 17:10  自由飞翔2012  阅读(157)  评论(0编辑  收藏  举报