• 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

Interface question....

 
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So, Interface's can only 'extend' other interfaces, right?

I thought they could implement one to many interfaces, but I guess they can only extend one to many interfaces.

Just wanted to make sure.

I also have an ENUM question as well,

in the following code:



I don't see how it knows that 'DOG("woof")' calls the enum's constructor without using a 'new' operator?

Thanks,

Justin Fox
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Justin,

Yes, interfaces use the "extends" keywords, followed by a list of extended interfaces -- there can be one or more. Classes extend classes, classes implement interfaces, interfaces extend interfaces, interfaces implement nothing.

About the enum: the compiler doesn't really "know" so much as it "assumes"; at that point, it's expecting to see enum values, and if it sees an open-paren, then that's assumed to be a constructor call. It "assumes' rather than "knows" because that's the only choice, and if the syntax turns out to be wrong, then it's an error.
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool deal,

Thanks for clearing that up for me.

I'm studying for the scjp so be prepared for mucho posts .

Thanks again,

Justin Fox
 
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
An enum is like a special kind of class. The enum constants are like public static final members of the class. Have a look at this:

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, once I figured out what it was 'assuming' i guess, I could kinda visualize a 'behind the scenes' declaration of the animals.

Thanks again,

Justin Fox
[ July 03, 2008: Message edited by: Justin Fox ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic