Skip to content

Instantly share code, notes, and snippets.

@gicappa
Last active August 29, 2015 14:03
Show Gist options
  • Save gicappa/12b447c263de3a1ec570 to your computer and use it in GitHub Desktop.
Save gicappa/12b447c263de3a1ec570 to your computer and use it in GitHub Desktop.
downcasting
class CurrentUser extends User {
public String who() {
return "who - CurrentUser class!";
}
}
class Main {
public static void main(String[] args) {
User user = new CurrentUser();
CurrentUser currentUser = (CurrentUser) user;
System.out.println(currentUser.who());
}
}
class User {
public String who() {
return "who - User class!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment