• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

public modifier for inner class

 
Ranch Hand
Posts: 65
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you try it out? Does the compiler give you an error when you try to compile this?
 
Ranch Hand
Posts: 453
Google Web Toolkit Hibernate Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 65
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
reply
    Bookmark Topic Watch Topic
  • New Topic