Javi

JAVA Puzzle: Menage a true

Sep 13th, 2013
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. package com.javiermoreno.dominajava.puzzlers;
  2.  
  3. import java.util.Random;
  4.  
  5. /**
  6.  *
  7.  *
  8.  * @author Java Puzzlers http://www.youtube.com/watch?v=yGFok5AJAyc
  9.  */
  10. public class Hamlet {
  11.  
  12.     public static void main(String[] args) {
  13.         Random rnd = new Random();
  14.         boolean toBe = rnd.nextBoolean();
  15.         Number result = (toBe || !toBe) ? new Integer(3) : new Float(1);
  16.         System.out.println("*****************");
  17.         System.out.println(result);
  18.        
  19.     }
  20.    
  21.    
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47. // El operador ternario no se comporta especialmente bien con diferentes tipos
Advertisement
Add Comment
Please, Sign In to add comment