wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes class within interface and interface within class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "class within interface and interface within class" Watch "class within interface and interface within class" New topic
Author

class within interface and interface within class

Yi Meng
Ranch Hand

Joined: May 07, 2003
Posts: 270
For these two cases, are there any implicit modifiers applied to the declaration(i.e. an interface member variable is implicitly "public static final")?
Thanks in advance.


Meng Yi
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Member interfaces declared in a class are always implicitly static. JLS 8.5.2
Member classes and interfaces declared in an interface are always implicitly static and public. JLS 9.5
Rajinder Yadav
Greenhorn

Joined: May 13, 2003
Posts: 27
take a look at this posting if you read and understand the basics here, it will help you with your question.
But basically you can declare a class within an interface, since an interface is defined as 'static abstract', what this mean is that a classes declared within the interface will be treated as a top level nested class.
here is a sample code to show how to declared a class bar inside an interface foo and then use it.
just make sure you understand the difference between a class and an interface, and that you understand inner classes and nest classes, this will clear up the question for you.... read the previous posting and look at the java sun tutorial s it explains the diff between an interface and class

NOTE:
class bar1 is declared with a defult access modifier
class bar2 had a public access modifier
class bar3 is an abstract class which is extended by class foobar3
notice how class scoping is used to extend class foobar3
[ May 15, 2003: Message edited by: Rajinder Yadav ]

When faced with an easy thing to do and a hard thing to do, always pick the right thing to do!<p><a href="http://yadav.shorturl.com" target="_blank" rel="nofollow">Rajinder Yadav</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class within interface and interface within class
 
Similar Threads
theortical questions
Class within Interface
interface (310-065)
Is there something called 'inner interface'?
Interfaces in java