Last active
August 29, 2015 14:14
-
-
Save mrbuk/38bc2f839492a3f40295 to your computer and use it in GitHub Desktop.
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
javac Verhalten.java RosVerhalten.java | |
java -cp RosVerhalten |
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 RosVerhalten implements Verhalten { | |
@Override | |
public void arbeiten() { | |
System.out.println("das mache ich weil ich es muss ..."); | |
} | |
@Override | |
public void chillen() { | |
System.out.println("Ach meine Leidenschaft ..."); | |
} | |
public void schlafen() { | |
System.out.println("Min. 8 Std. schlafe ich ..."); | |
} | |
public static void main(String args[]) { | |
Verhalten verhalten = new RosVerhalten(); | |
verhalten.arbeiten(); | |
verhalten.chillen(); | |
// verhalten.schlafen() -> funktioniert nicht! | |
// hier brauche ich einen CAST ... | |
((RosVerhalten) verhalten).schlafen(); | |
} | |
} |
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 Verhalten { | |
void arbeiten(); | |
void chillen(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cast sind keine Assignment Conversion. siehe http://docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#d5e5135 für Details.