Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Interfaces? [closed]

Tags:

java

oop

I really need help with interfaces in general...

Any resources that you guys would recommend me?

Related:

  • How are Java interfaces actually used?
  • Java interface and inheritance
  • Java Interface Usage Guidelines — Are getters and setters in an interface bad?
  • Why can’t I define a static method in a Java interface?
like image 984
Devoted Avatar asked Jan 06 '09 12:01

Devoted


2 Answers

What is an Interface? from Java's official tutorial

Edit: A second resource from the same tutorial, is the Interfaces and Inheritence section.

like image 50
Ali Avatar answered Sep 29 '22 12:09

Ali


In general:

You can see an interface as a contract or an agreement between two parties. So they can develop independently as long as the interface does not change.

The calling party, knows which behaviour is available and the implementing party knows what to implement.

There are a lot of advantages by using interfaces. One of them is that it is easy to switch between implementations. The other one is that classes can have different (inter)faces without using multiple inheritance.

like image 26
Toon Krijthe Avatar answered Sep 29 '22 14:09

Toon Krijthe