Type Conversions
You can use the Math methods on values of type int as well, but to get back an int result, you must convert the result by putting the type you want in ( ). This is called casting.
int x, y, z ;
x = 2 ;
y = 3 ;
z = ( int ) Math.pow ( x, y ) ;
Previous slide
Next slide
Back to first slide
View graphic version