//  Data Structures with Java by John R. Hubbard
//  Copyright McGraw-Hill, 2001
//  Example 3.5 on page 57
//  Casting primitive types

public class Ex0305
{ public static void main(String[] args) 
  { double x = 44.0;
    System.out.println("x = " + x);
    float y = (float)x;    // narrowing cast from double to float
    System.out.println("y = " + y);
    int n = (int)y;        // narrowing cast from float to int
    System.out.println("n = " + n);
    short m = (short)n;    // narrowing cast from int to short
    System.out.println("m = " + m);
    n = 65536 + 4444;
    System.out.println("n = " + n);
    m = (short)n;          // narrowing cast from int to short
    System.out.println("m = " + m);
    y = (float)m;          // widening cast from short to float
    System.out.println("y = " + y);
    y = (float)n;          // widening cast from int to float
    System.out.println("y = " + y);
  }
}
