• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using interface fields and members  RSS feed

 
Hector Zoltan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone, 1st message! (hooray!)

Anyway, I've begun learning Java recently, and I'm stuck...

How can I access an interface fields/members in an implementing class?

furthermore, since i cannot write any method bodies in an interface, why would I even WANT to have members inside an interface?

Thanks in advance to everyone who answers )
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

The Sun Java Tutorial has a section about interfaces.

An interface declaration can contain constants, not members/fields. You'd acces them like any field in a different class: something like "Interface.constantName"
[ December 31, 2006: Message edited by: Ulf Dittmer ]
 
Hector Zoltan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, great, thanks!

I was there, and couldn't find it specifically, so I played around a bit more with the eclipse 'till I found it

Thanks for your help anyway, and the fat reply!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!