午夜剧场伦理_日本一道高清_国产又黄又硬_91黄色网战_女同久久另类69精品国产_妹妹的朋友在线

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

java數(shù)據(jù)類型轉(zhuǎn)換,parseXXX(String)或valueOf(String)有什么區(qū)別?

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

問(wèn)題描述

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

問(wèn)題解答

回答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來(lái)說(shuō)明, valueOf 實(shí)際上調(diào)用了 parseInt。 parseInt方法是類Integer的靜態(tài)方法,它的作用就是將字符串轉(zhuǎn)化為整數(shù)int valueOf也是Integer類的靜態(tài)方法,它的作用是將字符串轉(zhuǎn)化為Integer對(duì)象

標(biāo)簽: java
主站蜘蛛池模板: 亚洲男人天堂2018 | 婷婷伊人综合中文字幕 | 久久久久亚洲精品国产 | 亚洲爱爱图| 日韩三级av | 亚洲一区在线免费观看 | 精品午夜一区二区三区在线观看 | 另类视频在线 | 91视频亚洲 | 久热香蕉视频 | 第一色综合 | 国产精品波多野结衣 | 国产综合精品视频 | 国产精品一区在线免费观看 | 久久影视中文字幕 | 欧美日本在线观看 | 网站av在线 | 亚洲精品一区二区三区在线播放 | av高清一区二区 | 日韩精品中文字幕在线 | 国产精品 | 国内久久 | 青青草社区 | 亚洲影视精品 | 国产精品久久久久久网站 | 青娱乐成人| 国产婷婷一区二区 | 成人在线精品视频 | 超碰激情| 久久综合一区二区 | 欧洲一区二区在线 | 五月天综合激情 | 成人18视频免费69 | av国产在线观看 | 影音先锋男人在线 | 色网免费| 天天宗合网 | 国产福利在线播放 | 国产福利在线看 | 午夜视频网址 | 97视频人人 |