/** * >>>>>>>>>>>>>>>>>> COPY TO BLUEJ AND RUN!!!! <<<<<<<<<<<<<<<<<< * MAKE SURE YOU UNDERSTAND WHAT IS GOING ON!!!!! * shows examples of how to convert between integers and doubles */ public class castExample { public static void main(String[] args) { // ---------------------- example 1 ------------------------------------- int someInt; double changeToDouble; someInt = 4; // casts an integer to a double changeToDouble = (double) someInt; System.out.println("someInt = " + someInt); System.out.println("changeToDouble = " + changeToDouble); // ---------------------- example 2 ------------------------------------- double someDouble; int changeToInt; someDouble = 2.9; // casts a double to an integer changeToInt = (int) someDouble; System.out.println("someDouble = " + someDouble); System.out.println("changeToInt = " + changeToInt); } }