This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Java in General and the fly likes interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "interfaces" Watch "interfaces" New topic


Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
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 this just an Eclipse issue?

I tried this:

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

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24193

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.)

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: interfaces
It's not a secret anymore!