Advertisement
Guest User

Untitled

a guest
Jan 25th, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. public class Main {
  2.  
  3.     public static void main(String[] args) {
  4.  
  5.         Integer i = new Integer(42);
  6.         Double d = new Double(3.14156);
  7.         String s = new String ("All your base are belong to us!");
  8.        
  9.         Object o = null;
  10.         handle(o);
  11.         o = i;
  12.         handle(o);
  13.         o = d;
  14.         handle(o);
  15.         o = s;
  16.         handle(o);
  17.     }
  18.  
  19.     private static void handle(String arg) {
  20.         System.out.println("It's a string!");
  21.     }
  22.    
  23.  
  24.     private static void handle(Number arg) {
  25.         System.out.println("It's a number!");
  26.     }
  27.    
  28.  
  29.     private static void handle(Double arg) {
  30.         System.out.println("It's a double!");
  31.     }
  32.    
  33.     private static void handle(Object arg) {
  34.         System.out.println("no idea what it is...");
  35.     }
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement