source: trunk/gcc/libjava/testsuite/libjava.lang/err3.java

Last change on this file was 2, checked in by bird, 22 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 1.4 KB
Line 
1/*--------------------------------------------------------------------------*/
2/* File name : err3.java */
3/* : */
4/* Cause : Evaluation sequence of the formula which used */
5/* : the substitution operator is not performed correctly. */
6/* : */
7/* Message : NG1:[27]-->[9] */
8/* : NG2:[27]-->[9] */
9/* : */
10/* Note : JLS 15.6 Evaluation Order (p305) */
11/* S15.6.1 Evaluate Left-Hand Operand First */
12/* : A formula should be evaluated to 9*3 instead of 3*3. */
13/*--------------------------------------------------------------------------*/
14
15public class err3 {
16 public static void main(String[] args) {
17 int x = 9;
18 x *= (x = 3);
19 if ( x == 27 ) {
20 System.out.println("OK1");
21 } else {
22 System.out.println("NG1:[27]-->["+x+"]");
23 }
24
25 int y = 9;
26 y = y * (y = 3);
27 if ( y == 27 ) {
28 System.out.println("OK2");
29 } else {
30 System.out.println("NG2:[27]-->["+y+"]");
31 }
32 }
33}
34
Note: See TracBrowser for help on using the repository browser.