Java examples for Language Basics:Number Cast
To cast a primitive value, use a cast operator.
A cast operator is the name of a primitive type in parentheses placed before the value you want to cast.
public class Main { public static void main(String[] args) { double pi = 3.1314; int iPi;// w w w. j av a2 s .com iPi = (int) pi; System.out.println(iPi); System.out.println(pi); } }