Think in java 答案

    技术2022-05-11  106

    阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx

    /****************** Exercise 1 ******************* There are two expressions in the section* labeled "precedence" early in this chapter.* Put these expressions into a program and* demonstrate that they produce different* results.***********************************************/public class E01_Precedence {  static int a,    x = 40,    y = 60,    z = 10;  public static void main(String[] args) {    a = x + y - 2/2 + z;    System.out.println(a);    a = x + (y - 2)/(2 + z);    System.out.println(a);  }} 

    //+M java E01_Precedence

    **Results are 109 & 44. The difference is because the default order of evaluation is changed by the use of the parentheses.


    最新回复(0)