When you do things right, people won't be sure you've done anything at all.
When you do things right, people won't be sure you've done anything at all.
Jon Manson wrote:So what exactly does an interface do?
Jon Manson wrote:Is it no different than making a class?
When you do things right, people won't be sure you've done anything at all.
Jon Manson wrote:I'm sorry about not getting this, but I still don't understand.
What do you mean by - a contract between itself and the implementing class
What is the contract?
Jon Manson wrote:Thanks, but how is an interface different to an abstract class?
Jon Manson wrote:So, abstraction is when a class is broadly defined and cannot be instantiated.
Is an interface a class which has all methods in it abstract?
In its most common form, an interface is a group of related methods with empty bodies.
James Clarks wrote:An interface class IS an abstract class.
public abstract interface ForumReader {
}
When the programmer leaves out the 'abstract' keyword from the code, the compiler will interpret the keyword 'interface' and will automatically add the internal code for 'abstract'. This occurs prior to bytecode generation. This is part of advanced source code parsing and beyond the scope of "Beginning Java".
John de Michele wrote:
James Clarks wrote:An interface class IS an abstract class.
public abstract interface ForumReader {
}
When the programmer leaves out the 'abstract' keyword from the code, the compiler will interpret the keyword 'interface' and will automatically add the internal code for 'abstract'. This occurs prior to bytecode generation. This is part of advanced source code parsing and beyond the scope of "Beginning Java".
However, you can't have a concrete top-level class extend an interface, which makes them different than 'regular' abstract classes. I just tried this:
Apparently java (or its error messages, at least) doesn't think of interfaces as classes: I got the error "The type List<String> cannot be the superclass of Sandbox; a superclass must be a class".
John.
Jon Manson wrote:So what exactly does an interface do?
Well behaved women rarely make history - Eleanor Roosevelt. tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|