Advertisement
Edstar

Java / 2-6 / Conversion

Nov 28th, 2015
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.48 KB | None | 0 0
  1. class Conversion {
  2.     public static void main(String[]args){
  3.         byte b;
  4.         int i = 257;
  5.         double d = 456.789;
  6.        
  7.         System.out.println("\n conversion of int to byte.");
  8.         b = (byte) i;
  9.         System.out.println("i and b "+ i +" "+b);
  10.         System.out.println("\n conversion of double to int.");
  11.         i = (int) d;
  12.         System.out.println(" d and i "+ d +" "+i);
  13.         System.out.println(" \n conversion of double to byte.");
  14.         b = (byte) d;
  15.         System.out.println(" d and b "+ d +" "+b);
  16.        
  17.     }
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement