1 /*--------------------------------------------------------------------------*/ 2 /* File name : err6.java */ 3 /* : */ 4 /* Cause : Array evaluation order */ 5 /* : */ 6 /* Message : NG:[1]-->[4] */ 7 /* : */ 8 /* Note : JLS 15.9 Array Creation Expressions (p315--) */ 9 /* : p318 line3 */ 10 /* :[Each dimension expression is fully evaluated */ 11 /* : before any part of any dimension expression to its right.] */ 12 /*--------------------------------------------------------------------------*/ 13 14 public class err6 { main(String[] args)15 public static void main(String[] args) { 16 int[] x = { 10, 11, 12, 1, 14 }; 17 int[] y = { 1, 2, 3, 4, 5, 6 }; 18 19 if ( x[(x=y)[2]] == 1 ) { 20 System.out.println("OK"); 21 } else { 22 System.out.println("NG:[1]-->[" +x[(x=y)[2]]+ "]"); 23 } 24 } 25 } 26 27