and then I move the code from "class B"(ListXMLParser.java) to "class A"(ListMode.java) .
(It looks I change the declaring class to enclosing class) and get the error : "No enclosing instance of type xxx is accessible. "
Full Error msg :
No enclosing instance of type ListXMLParser is accessible. Must qualify the allocation with an enclosing instance of type ListXMLParser (e.g. x.new A() where x is an instance of ListXMLParser).
And i get a nice answer from internet, that is from seh in stackoverflow.
he said need add the "static" for enclosing class. For my case:
Before
public class ListModel { ... }After
public static class ListModel { ... }
Related image:
Original answer :
5
|
If you change class
MyThread to be static, you eliminate the problem:
Since your
main() method is static, you can't rely on non-static types or fields of the enclosing class without first creating an instance of the enclosing class. Better, though, is to not even need such access, which is accomplished by making the class in question static. | ||
add comment |
Reference:
http://stackoverflow.com/questions/12471664/no-enclosing-instance-of-type-is-accessible
No comments :
Post a Comment