This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes public modifier for inner class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "public modifier for inner class" Watch "public modifier for inner class" New topic
Author

public modifier for inner class

Jeena Jeen
Ranch Hand

Joined: Feb 11, 2009
Posts: 47
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

Joined: Aug 16, 2005
Posts: 14074
    
  16

Did you try it out? Does the compiler give you an error when you try to compile this?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452

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

SCJP 5.0 SCWCD 5.0
avi sinha
Ranch Hand

Joined: Mar 15, 2009
Posts: 452



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

Joined: Apr 24, 2009
Posts: 30
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

Joined: Feb 11, 2009
Posts: 47
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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: public modifier for inner class
 
Similar Threads
Doubt regarding Inner Class
inner classes
Question about top-level nested class/static inner class
Question - Philip Heller's book
Inner Interfaces