//********************************Start**************************
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author HP
*/
public class Java_Type_Casting {
public static void main(String args[])
{
byte b;
int i = 257;
double d = 323.142;
System.out.println("Conversion of int to byte.");
b = (byte) i;
System.out.println("i is " + i + " and b is " + b);
System.out.println("\nConversion of double to int.");
i = (int) d;
System.out.println("d is " + d + " and i is " + i);
System.out.println("\nConversion of double to byte.");
b = (byte) d;
System.out.println("d is " + d + " and b is " + b);
}
}
//********************************End***************************
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;
/**
*
* @author HP
*/
public class Java_Type_Casting {
public static void main(String args[])
{
byte b;
int i = 257;
double d = 323.142;
System.out.println("Conversion of int to byte.");
b = (byte) i;
System.out.println("i is " + i + " and b is " + b);
System.out.println("\nConversion of double to int.");
i = (int) d;
System.out.println("d is " + d + " and i is " + i);
System.out.println("\nConversion of double to byte.");
b = (byte) d;
System.out.println("d is " + d + " and b is " + b);
}
}
No comments:
Post a Comment
Welcome, happy learning