import java.util.*;
class casting
{
public static void main (String arg[])
{
Scanner in = new Scanner (System.in);
int a;
short b;
byte c;
System.out.print ("\n\t Enter the value = ");
a=in.nextInt();
b=(short)a;
c=(byte)a;
System.out.println ("\n\t value of a in short form = "+b);
System.out.println ("\n\t Value of a in byte form= "+c);
}
}
Note:
In the above program you might have noticed these two statements
- b=(short)a;
- c=(byte)a;
No comments:
Post a Comment