Interface (Java): Difference between revisions

Content deleted Content added
No edit summary
Tag: Reverted
Reverting edit(s) by 122.56.77.149 (talk) to rev. 1100622878 by PlanetJuice: Vandalism (RW 16.1)
Line 9:
 
Another use of interfaces is being able to use an [[Object (computer science)|object]] without knowing its type of class, but rather only that it implements a certain interface. For instance, if one were annoyed by a whistling noise, one may not know whether it is a human or a parrot, because all that could be determined is that a whistler is whistling. The call <code>whistler.whistle()</code> will call the implemented method <code>whistle</code> of object <code>whistler</code> no matter what class it has, provided it implements <code>Whistler</code>. In a more practical example, a [[sorting algorithm]] may expect an object of type {{Javadoc:SE|java/lang|Comparable}}. Thus, without knowing the specific type, it knows that objects of that type can somehow be sorted.
 
Poggers fortntie gameplay
For example:
<syntaxhighlight lang="Java">