File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Static Inner Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Static Inner Class" Watch "Static Inner Class" New topic

Static Inner Class

Paras Ahuja
Ranch Hand

Joined: May 22, 2012
Posts: 62
Hi everyone, shows error. Please help me....
Matthew Brown

Joined: Apr 06, 2010
Posts: 4524

It's generally helpful to say what the errors are.'s nothing to do with the fact that it's an inner class (note - it isn't a static inner class, it's just a normal inner class). The error is because you have a statement directly in a class body instead of being within a method.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347

moreover, since ABC is not a static class, even if it had a method to call you need an instance of Try class in order to call it.

what you must be trying to do is have a Static inner class
public static class ABC
then you can call it like this

Visit my download page
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Not to add any confusion, but just to be pedantic, I don't think there is such a thing as a static inner class. Static nested class, yes, but I believe the term "inner class" is defined by the JLS to only apply to non-static nested classes.
I agree. Here's the link:
subject: Static Inner Class