Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: usere4d07
Added: Sep 30, 2019 4:35 PM
Views: 10
Tags: no tags
  1. abstract class Printer {
  2.  
  3.     public abstract void print(String s);
  4.  
  5.     public void print(int integer) {
  6.         print(Integer.toString(integer));
  7.     }
  8. }
  9.  
  10. public class FilePrinter extends Printer {
  11.  
  12.     @Oberride
  13.     public void print(String s) {
  14.         // write to file
  15.     }
  16. }
  17.  
  18. public class ConsolePrinter extends Printer {
  19.  
  20.     @Oberride
  21.     public void print(String s) {
  22.         System.out.println(s);
  23.     }
  24. }