package com.tutego.insel.generics;

public class GenericBoxExample4
{
  @SuppressWarnings("unused")
  public static void main( String[] args )
  {
    Box<Number>  numberBox;
    Box<Integer> bI = new Box<Integer>();
    Box<Double>  bD = new Box<Double>();
//    numberBox = bI;                            // Compilerfehler Type mismatch
    
    Box<?> b;
    
    Box<? extends Number> numbersBox;
    Box<Integer> intBox    = new Box<Integer>();
    Box<Double>  doubleBox = new Box<Double>();
    Box<String>  stringBox = new Box<String>();

    numbersBox = intBox;  // oder numbersBox = doubleBox; 
//    numbersBox = stringBox;  // Type mismatch

//    numbersBox.setValue( 1 );  // Compilerfehler
    intBox.setValue( 1 );
    Number number = numbersBox.getValue();
    System.out.println( number );  // 1
  }
}
