• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Static Inner Class

 
Paras Ahuja
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,



t.show shows error. Please help me....
 
Matthew Brown
Bartender
Posts: 4567
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's generally helpful to say what the errors are.

However...it'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
Posts: 4444
3
Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Try.ABC.someMethod();
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic