sequence point concept in java

后端 未结 2 486
栀梦
栀梦 2020-12-06 02:25

I am new to Java and have background of C.I am going through Khalid Moughal\'s book. On page 126 he gives an example as

   int i = 10;

   int k = ++i + --i         


        
相关标签:
2条回答
  • 2020-12-06 02:50

    My question is does the same sequence point rule applies in java or not?

    No, there are no sequence-points in Java. Order of evaluation (etc) is well defined in Java.

    Also read this answer.

    0 讨论(0)
  • 2020-12-06 02:53

    No, there are no concept of sequence-points in java and the order of is fully defined. Generally speaking, expressions are evaluated from left to right.For formal definition, you can read JLS, section 15.7 about the evaluation order. See this link.

    0 讨论(0)
提交回复
热议问题