Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Nested Interface

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am preparing for SCJP1.4.I refer to Programmer's Guide to Java� Certification, A: A Comprehensive Primer, Second by Khalid A. Mughal, Rolf W. Rasmussen. I have a doubt related to the Chapter 7.Nested Classes and interfaces. In this chapter the authour mention in the section 7.1 Overview of Nested Classes and Interfaces, that "Note that there are no non-static member, local, or anonymous interfaces. Interfaces are always defined either at the top level or as static members."
But in the next section 7.2 Static Member Classes and Interfaces, it declares a non-static interface in a static context. I would like to know if an interface is defined in a static context without the static keyword, will the interface still be called static?
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kutty

A "nonstatic member type" is simply a member type that is not declared static. Since interfaces, enumerated types, and annotations are always implicitly static, however, we usually use the term "nonstatic member class" instead. So what the author is saying is correct if you consider this "Interfaces are impliciltly static".

Check some other books to clarify this. Good observation. Keep It UP.

All The Best.
[ August 03, 2007: Message edited by: Sridhar Padala ]
 
Ranch Hand
Posts: 368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please explain this

Interfaces are impliciltly static



Does it mean that if I have a memeber interface in a class, I can only use it in a static context. For e.g. consider this

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Interfaces are not implicitly static.The variables declared in the interface have "public static final" modifiers. Any variable or method (members) declared as static can be accessed by using the Class Name / Interface Name directly.

The static members can be called both in a static / non-static context.A class can be given only
1.default or public access modifiers
2.strictfp modifier
3.final
4.abstract modifier nothing other than that.

Coming to point, an interface has
1.public/default access modifiers
2.abstract modifer - by default

I hope i answered your query.
 
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
kishore kishore, please check your private messages. You can see them by clicking "My Profile" at the top right of the page.
 
girl power ... turns out to be about a hundred watts. But they seriuosly don't like being connected to the grid. Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic