posts - 4,comments - 1,trackbacks - 0
          boolean b=new Boolean(s).booleanValue(); int i=Integer.parseInt(s); long l=Long.parseLong(s); double d=Double.parseDouble(s);
          posted on 2006-03-25 16:29 我的JAVA世界 閱讀(542) 評論(1)  編輯  收藏

          FeedBack:
          # re: JAVA中將字符串s轉換到其他的基本類型
          2006-04-04 20:13 | 閑來觀云
          其實new Boolean(s).booleanValue()和Boolean.parseBool(s)是一個效果。。下面是Boolean類的部分代碼。。。

          /*
          * @(#)Boolean.java 1.51 04/05/11
          *
          * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
          * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
          */

          package java.lang;

          public final class Boolean implements java.io.Serializable,
          Comparable<Boolean>
          {

          private final boolean value;

          public Boolean(boolean value) {
          this.value = value;
          }

          public Boolean(String s) {
          this(toBoolean(s));
          }

          public boolean booleanValue() {
          return value;
          }

          public static boolean parseBoolean(String s) {
          return toBoolean(s);
          }

          private static boolean toBoolean(String name) {
          return ((name != null) && name.equalsIgnoreCase("true"));
          }
            回復  更多評論
            

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 云浮市| 若尔盖县| 鹤峰县| 长乐市| 鄂州市| 阳新县| 开鲁县| 拉孜县| 丹棱县| 禹城市| 江达县| 南召县| 金乡县| 上蔡县| 江油市| 三门峡市| 壤塘县| 灵台县| 海口市| 芒康县| 郁南县| 青阳县| 深泽县| 高尔夫| 金塔县| 平原县| 津南区| 水城县| 三明市| 香格里拉县| 额济纳旗| 普兰县| 胶南市| 黔东| 湘乡市| 普陀区| 马鞍山市| 泾源县| 康平县| 长岛县| 中江县|