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

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

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

瀏覽:92日期: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
主站蜘蛛池模板: 国产激情偷乱视频一区二区三区 | 国产欧美一区二区精品忘忧草 | www.日韩系列 | 精品国产精品国产偷麻豆 | 国产一级久久久久 | 午夜三区 | 狠狠躁天天躁夜夜躁婷婷老牛影视 | 国产精品区一区二区三区 | 国产一级片av| 亚洲精品播放 | 青青草社区 | 性高湖久久久久久久久 | 一区二区三区四区av | 91影院 | 福利精品| 中文字幕一区在线观看视频 | 免费成人在线网站 | 国产精品久久久久久久久久久久久 | 日韩一区二区在线视频 | 久久久精 | 久久一区视频 | 国产精品九九九 | 亚洲视频免费 | 欧美中文在线 | 欧美日韩久久久 | 国产精品综合视频 | 久久com| 国产成人精品一区二区 | 欧美黄色网络 | 欧美一区二区网站 | 日本精品一区二区三区四区 | 国产免费黄网 | 久久久亚洲一区 | 亚洲综合一区二区三区 | 亚洲视频观看 | 久久久精品视频免费看 | 日韩一区二区在线视频 | 亚洲五码在线 | 亚洲精品免费视频 | 韩日精品一区 | 91伦理片 |