Cast a float or double to an integral value


public class CastingNumbers {

  public static void main(String[] args) {

    double above = 0.7, below = 0.4;

    System.out.println("above: " + above);

    System.out.println("below: " + below);

    System.out.println("(int)above: " + (int)above);

    System.out.println("(int)below: " + (int)below);

    System.out.println("(char)('a' + above): " +  (char)('a' + above));

    System.out.println("(char)('a' + below): " +  (char)('a' + below));
  }
}
Home 
  Java Book 
    Runnable examples  

Data Type Float:
  1. Cast a float or double to an integral value
  2. Create Float from float value
  3. Compare Float
  4. Convert float to string
  5. Convert Float to Numeric Primitive Data Types
  6. Is Float infinite
  7. Is Float Not a Number(isNaN)
  8. Min and Max value of float type