/***************************************************************** * Program: Type Casting * * Class: COMP 110-001 Instructor: Yi Hong * * Description:This program type casts different variables * Input: none * * Output: messages ******************************************************************/ public class TypeCasting { public static void main(String[] args) { double myDouble = 5.55; int myInt = 3; System.out.println("I can put an int into a double"); myDouble = myInt; System.out.println("myDouble = " + myDouble); System.out.println("myInt = " + myInt); myDouble = 5.55; System.out.println("To assign myDouble to myInt I must type cast."); myInt = (int)myDouble; System.out.println("And now..."); System.out.println("myDouble = " + myDouble); System.out.println("myInt = " + myInt); } }