1 /*--------------------------------------------------------------------------*/ 2 /* Name : N19990310_4.java */ 3 /* : */ 4 /* Cause : assignment operator makes error in char,byte,short variable */ 5 /* : */ 6 /* Message : In class `N19990310_4': */ 7 /* : In method `main(java.lang.String[])': */ 8 /* : Incompatible type for `='. Explicit cast needed to convert `*/ 9 /* : `int' to `char'. */ 10 /* : x += (x = 3); */ 11 /* : ^ */ 12 /* : 1 error */ 13 /*--------------------------------------------------------------------------*/ 14 15 public class N19990310_4 { main(String[] args)16 public static void main(String[] args) { 17 char x = 9; 18 19 x += (x = 3); 20 if ( x == 12 ) { 21 System.out.println("OK"); 22 } else { 23 System.out.println("NG"); 24 } 25 } 26 } 27 28