Byte from Integer and Double

package ch4_package;
import java.io.*;
public class Test_This {
public static void main(String[] args) throws IOException
{
// TODO Auto-generated method stub
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
String str = "";
try{
System.out.println("---While Loop---");
System.out.print("Please enter double data: ");
str = br.readLine();
//int n =Integer.parseInt(str);
double n = Double.parseDouble(str);
int i=12 , b1;
byte b;
if (i <= n){
System.out.println("You are allowed in this ride: ");
b = (byte)n;//explicit conversion from double to byte
b1 = b; //implicit conversion from byte to integer
System.out.println("byte=integer and byte = byte used: "+ b + "\t" + b1 + "\t"+ n);
}
else
{
System.out.print("sorry you cant' go in ths ride: ");
}
System.out.println();
}//try
catch(NumberFormatException e) { System.out.println("data was blank");}
}
}

 

The above example show how to convert (explicit) from double data type to byte and implicit conversion b1=b from byte to integer.