Last active
August 29, 2015 13:58
-
-
Save arinto/9994695 to your computer and use it in GitHub Desktop.
A very simple Awesome interface
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Awesome { | |
/** | |
* say hello! | |
*/ | |
void sayHello(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AwesomeSpaniard implements Awesome { | |
@Override | |
public void sayHello() { | |
System.out.println("Hola!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BasicMain { | |
public static void main(String[] args) { | |
List<Awesome> awesomePeople = new LinkedList<>(); | |
Awesome spaniard = new AwesomeSpaniard(); | |
awesomePeople.add(spaniard); | |
Awesome indonesian = new AwesomeIndonesian(); | |
awesomePeople.add(indonesian); | |
Awesome swedish = new AwesomeSwedish(); | |
awesomePeople.add(swedish); | |
Awesome singaporean = new AwesomeSingaporean(); | |
awesomePeople.add(singaporean); | |
awesomePeople.forEach(ap -> ap.sayHello()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hola! | |
Halo! | |
Hej hej! | |
Hello! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment