Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

public modifier for inner class

 
Jeena Jeen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Is it possible to have more than one public Inner Class.


I know that its not possible to have more than one public modifier for outer class in same file. But what about inner class?
And one more question for inner class. I read some where that for inner class Abstract, Final pair is legal for inner class?
Is it true? Can anyone please explain this to me that how come we can use Abstract and Final pain for inner class and not for outer class?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you try it out? Does the compiler give you an error when you try to compile this?
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think there is no problem in it.as per i know inner classes can have any modifier.
I read some where that for inner class Abstract, Final pair is legal for inner class?

it can never be legel.

avi
 
avi sinha
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


-------------------Configuration: <Default>--------------------
C:\Documents and Settings\avi\My Documents\coding\gfh.java:2: illegal combination of modifiers: abstract and final
abstract final class Inner{
^
1 error

Process completed.
 
Eugene Rabii
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. An inner class is treated just like a member of the class, so it can have any access modifiers (private, public protected or default). Is it possible to have more then one public integers inside a class declaration? of course yes, then the answer is of course yes for inner classes.

2. final abstract is never legal - for any type of classes. What you have probably read is that private can not be declared with abstract, but of course that is only legal for an inner class.
P.S. As for me this simple rule always helps me remember that abstract strictfp is illegal for a method, but legal for a class.

Thank you,
Eugene.
Jeena Jeen wrote:Hi all,
Is it possible to have more than one public Inner Class.


I know that its not possible to have more than one public modifier for outer class in same file. But what about inner class?
And one more question for inner class. I read some where that for inner class Abstract, Final pair is legal for inner class?
Is it true? Can anyone please explain this to me that how come we can use Abstract and Final pain for inner class and not for outer class?
 
Jeena Jeen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys. I think I must have read something wrong. I tried to compile it as well. Indeed its not true.
Thanks for your replies..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic