Whats is as Cast ?
A cast is an explicit conversion.
In the below program we convert values from double to int.
===conversiontypes.java======
public class converisontypes {
public static void main (String[] args) {
double x,y;
x=20;
y=10;
int z;
z = (int) (x/y);
System.out.println("The Value of Z is " +z);
}
}
========================
result:
The Value of Z is 2
A cast is an explicit conversion.
In the below program we convert values from double to int.
===conversiontypes.java======
public class converisontypes {
public static void main (String[] args) {
double x,y;
x=20;
y=10;
int z;
z = (int) (x/y);
System.out.println("The Value of Z is " +z);
}
}
========================
result:
The Value of Z is 2
No comments:
Post a Comment