Widening casting is done automatically when passing a smaller size type to a larger size type:
for ex:
public class Main {
public static void main(String[] args) {
int myInt = 9;
double myDouble = myInt;
System.out.println(myInt);
System.out.println(myDouble);
}
}
Narrowing casting must be done manually by placing the type in parentheses in front of the value:
for ex:
public class Main {
public static void main(String[] args) {
double myDouble = 9.78d;
int myInt = (int) myDouble;
System.out.println(myDouble);
System.out.println(myInt);
}
}