Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sound {
- private int sound;
- void setSound(final int sound) {
- this.sound = sound;
- }
- }
- class NoSound extends Sound {
- @Override
- void setSound(final int sound) {
- // empty, we dont want to set sound!
- }
- public void music() {
- super.setSound(5) // this makes a refference to the super -> Sound#setSound method, so this will set the sound variable to a desired value
- setSound(5) // while this makes a refference to THIS instance, so it will reffer to NoSound#setSound so our sound value wont change
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement