av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

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

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

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

問題描述

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

問題解答

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

標(biāo)簽: java
主站蜘蛛池模板: 欧美男人天堂 | 日韩中文字幕在线 | 天堂免费av | 免费在线a | 中文字幕在线看 | 黄色资源在线观看 | 四虎在线免费视频 | 日韩在线高清 | 久在线视频 | 色污污 | 国产在线不卡视频 | 欧美xx孕妇 | 一级免费视频 | 亚洲精品第一 | 黄色一级视频网站 | www视频在线观看网站 | 亚洲乱码一区二区 | 国产成人91 | 国产欧美日韩在线观看 | 97av在线| 免费91网站| 国产精品看片 | 日本成人免费 | 日韩黄色一级视频 | xxxxx黄色| 国产视频一区二区在线观看 | 亚洲国产片 | 国产激情久久久 | 亚洲一区二区免费视频 | 国产精品视频久久 | 日本丰满少妇做爰爽爽 | 午夜影院免费 | 欧美激情国产精品 | 久久国产精 | 一区二区三区免费在线观看 | 99热99re6国产在线播放 | 国产午夜精品久久 | 黄色激情网站 | 日韩在线精品 | 久久综合国产 | 中文字幕婷婷 |