亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術文章
文章詳情頁

java數據類型轉換,parseXXX(String)或valueOf(String)有什么區別?

瀏覽:62日期:2023-12-08 14:01:25

問題描述

基本類型的包裝類的parseparseXXX(String)和valueOf(String)有什么區別呀?

問題解答

回答1:

JDK8源碼

/** * Returns an {@code Integer} object holding the value * extracted from the specified {@code String} when parsed * with the radix given by the second argument. The first argument * is interpreted as representing a signed integer in the radix * specified by the second argument, exactly as if the arguments * were given to the {@link #parseInt(java.lang.String, int)} * method. The result is an {@code Integer} object that * represents the integer value specified by the string. * * <p>In other words, this method returns an {@code Integer} * object equal to the value of: * * <blockquote> * {@code new Integer(Integer.parseInt(s, radix))} * </blockquote> * * @param s the string to be parsed. * @param radix the radix to be used in interpreting {@code s} * @return an {@code Integer} object holding the value * represented by the string argument in the specified * radix. * @exception NumberFormatException if the {@code String} * does not contain a parsable {@code int}. */public static Integer valueOf(String s, int radix) throws NumberFormatException { return Integer.valueOf(parseInt(s,radix));}

這里用Inteager來說明, valueOf 實際上調用了 parseInt。 parseInt方法是類Integer的靜態方法,它的作用就是將字符串轉化為整數int valueOf也是Integer類的靜態方法,它的作用是將字符串轉化為Integer對象

標簽: java
主站蜘蛛池模板: 一级毛片a| 欧美午夜精品 | 免费大黄网站在线看 | 亚洲欧美国产毛片在线 | 久久草在线视频播放 | 妖精视频永久在线入口 | 51精品视频免费国产专区 | 欧美一级毛片兔费播放 | 午夜羞羞视频在线观看 | 成人午夜免费在线观看 | 精品日韩在线视频 | 日韩在线观看第一页 | 国产高清免费在线观看 | 一级黄大片 | 欧美亚洲国产第一页草草 | 在线精品视频成人网 | 中文在线免费看视频 | 大陆一级黄色片 | 丁香激情网 | 久久精品亚洲综合一品 | 国产一区二区三区免费播放 | 久久麻豆亚洲精品 | 国产精品久久一区一区 | 欧美黄网站 | 香蕉视频免费在线观看 | 欧美日韩国产58香蕉在线视频 | 宅男69免费永久网站 | 日韩成人黄色片 | 免费观看一级成人毛片软件 | 特a级毛片 | 国产日韩欧美成人 | 亚洲欧美久久婷婷爱综合一区天堂 | 九九综合九九综合 | 91福利国产在线在线播放 | 国产传媒网址 | 黄色变态视频 | 国产三区视频在线观看 | 日韩精品中文字幕在线 | 免费观看片 | 国产原创一区二区 | 黄色影院 |