1.
          If operators with the same precedence are next to each other, there associativity determines the order of evaluation. All binary operators except assignment operators are left-associative.
          Assignment operators are right-associative. Therefore, the expression
          a = b += c = 5 equivalent a = (b += (c = 5))

          If no operands hava side effects that change the value of a variable, the order of operand evaluation is irrelevant. Interesting cases arise when operands do hava a side effect. For example,

          public class TestDemo {
          public static void main(String arg[]) {
          int a = 0;
          int x = ++a + a;
          System.out.println(x);
          a = 0;
          x = a + (++a);
          System.out.println(x);
          }
          }

          The output will be:
          2
          1

          The order for evaluation operands takes precedence over the operator precedence rule. In the former case, (++a) has higher precedence than addition (+), but since a is a left-hand operand of the addition (+), it is evaluated before any part of its right-hand operand (e.g., ++a in this case).

          2.
          Converting Strings to Numbers:
          int intValue = Integer.parseInt(intString);
          double doubleValue = Double.parseDouble(doubleString);

          parseInt

          public static int parseInt(String s)
          throws NumberFormatException
          
          Parses the string argument as a signed decimal integer. The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.
          Parameters:
          s - a String containing the int representation to be parsed
          Returns:
          the integer value represented by the argument in decimal.
          Throws:

          NumberFormatException - if the string does not contain a parsable integer.

          3.
          Format to keep two digits after the decimal point:
          double doubleValue = (int)(doubleValue2 * 100) / 100.0

          4.
          Computing ab:
          public static double pow(double a, double b)


          posts - 403, comments - 310, trackbacks - 0, articles - 7
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          1.21 Java notes

          Posted on 2007-04-22 20:22 ZelluX 閱讀(140) 評論(0)  編輯  收藏 所屬分類: OOP
          2007-01-21 21:57:20
          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 永仁县| 合肥市| 南皮县| 商南县| 宜阳县| 广平县| 樟树市| 淮阳县| 阿坝县| 泽库县| 甘德县| 吴忠市| 松溪县| 老河口市| 阿坝县| 丘北县| 益阳市| 荥阳市| 内乡县| 海伦市| 湖北省| 喜德县| 安义县| 正蓝旗| 大姚县| 芦溪县| 若尔盖县| 泸州市| 桐庐县| 广宗县| 旺苍县| 忻州市| 类乌齐县| 台州市| 东阿县| 嵩明县| 江达县| 治多县| 彭阳县| SHOW| 拜城县|