Java/Interfaces: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 10: | Line 10: | ||
[[Category:Java]] | [[Category:Java]] | ||
{{CSFlag}} | |||
Revision as of 01:44, 11 June 2017
Interfaces: https://docs.oracle.com/javase/tutorial/java/concepts/interface.html
I like to describe interfaces as inheritance lite - they provide some useful guarantees about the way an interface to a class will work, without the restrictive requirements that come with inheritance. A classic example is an interface indicating something can make noise - babies and monster trucks both make noise, but there is not much more they have in common, ontologically.
An interface requires a class to provide certain methods. A good example of this is for Tree data structures (see also Data Structures and Abstract Data Types). The abstract implementation of methods that any tree should implement, but that will depend on their concrete implementation, can be defined by an interface, and actually implemented in the class that implements the interface.
| Computer Science notes on computer science topics on the wiki, for educational and learning purposes
Part of the 2017 CS Study Plan.
Python/Exceptions · Python/Assertions · Python/Decorators Python/Os (os module) · Python/Strings Python/Splat · Python/Iterators · Python/Generators Python/Comparators · Python/Lambdas
Builtin features of Java: Java/Exceptions · Java/Assertions · Java/Memory · Java/Interfaces Java/Generics · Java/Decorators · Java/Diamond Notation Java/Iterators · Java/Iterable · Iterators vs Iterable Java/Comparators · Java/Comparable · Comparators vs Comparable Java/Numeric · Java/TypeChecking · Java/Testing · Java/Timing · Java/Profiling Documentation: Javadocs · Java/Documentation Tools and functionality: Java/URLs · Java/CSV External libraries: Guava · Fastutil · Eclipse Collections OOP: OOP Checklist · Java/Abstract Class · Java/Encapsulation · Java/Generics
|
See also: