This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

interfaces

 
Vinnie Jenks
Ranch Hand
Posts: 207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a long-time C# cat trying to translate my skills over to Java.

In C#, when I create an interface I can use it as a means of declaring a type in an abstract manner, like so:



Does it work this way in Java? I'm using Eclipse and it's telling me it can't find my interfaces as types...is this just an Eclipse issue?

I tried this:



If this is a Java "gotcha", are abstract classes the same?

Thanks!
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your example Java code is exactly right; the devil is in the details, though, so perhaps some detail is wrong in your real code. Maybe it's a package thing? Make sure the package containing the interface is imported when you compile your other code (assuming everything's not in one package.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic