The interface will 'specify' the signature that every class will
implement. As in the parameters that get passed to each method.
A interface "method" looks like:
foo( Object 0, int i);
I can't tell in my font what the variable name is for the "Object" parameter,
but it isn't an upper- or lower-case letter 'oh'. I expect a lower-case 'o'
was intended.
The class that implements it is very simalar:
void foo(Object 0, int i){
//do stuff with objects and an int
}
The similarity to which maxnesler alludes is that the method signature is the
same - that's the part from "void" through the closing parenthesis.
What maxnesler forgot to show is that the implementing class declares the
method to be 'public', which is implied automatically in the interface
declaration but not so for the class declaration, and the class as
implementing the interface, the penalty for giving such an incomplete example.
package foo;
public interface Fooish
{
public void foo( Object o, int i );
}
Separate file:
package bar;
import foo.Fooish;
public class Foo implements Fooish
{
public void foo( Object o, int i )
{
// do stuff ...
}
}
The difference is that the interface has only a semicolon for a method "body",
but a class has to declare a real method body. Note that the class explicitly
'implements' the interface. This sets up an inheritance ("is-a") relationship
between the interface and the class. Now the interface can be used as the
abstract supertype for the implementation.
Some other file:
...
public void bax()
{
Fooish fooish = new Foo();
fooish.foo( new Object(), 17 );
}