CS 101 - 10/6/11 Increment and Decrement operators ++ increases the value by 1 -- decreases the value by 1 int x; x = 7; // examples of the post-increment operator x++; // increments the value to 8 x--; // decrements the value back to 7 // examples of the pre-increment operator ++x; // increments gthe value to 8 --x; // decrements the value back to 7 Even though the world mostly uses post-increment we should be using the pre-increment Examples of confusion with the ++ operator y = x++; or y = ++x; The above is poor programming style because is causes two variables to be modified in a single statement. Good style has us only modifying a single variable per statement. Type Error - When we are assigning a value of one type into a variable of another type, we may cause a compiler error Type Cast: change a value from one type to another type y = (type) x; Change the value from x to the type indicated inside the parantheses and then store the value into y. y = (int) x;