国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

華為OJ——字符串逆序

2019-11-08 02:50:39
字體:
來源:轉載
供稿:網友

題目:字符串逆序輸出

代碼:

vauleOf():The valueOf method returns the relevant Number Object holding the value of the argument passed. The argument can be a PRimitive data type, String, etc.This method is a static method. The method can take two arguments, where one is a String and the other is a radix.Return Vaule:

valueOf(int i) ? This returns an Integer object holding the value of the specified primitive.

valueOf(String s) ? This returns an Integer object holding the value of the specified string representation.

valueOf(String s, int radix) ? This returns an Integer object holding the integer value of the specified string representation, parsed with the value of radix.

public class Test {    public static void main(String args[]) {      Integer x =Integer.valueOf(9);      Double c = Double.valueOf(5);      Float a = Float.valueOf("80");                     Integer b = Integer.valueOf("444",16);      System.out.println(x);       System.out.println(c);      System.out.println(a);      System.out.println(b);   }}
95.080.01092String 類別中已經提供了將基本數據型態轉換成 String 的 static 方法 也就是 String.valueOf() 這個參數多載的方法 有下列幾種 String.valueOf(boolean b) : 將 boolean 變量 b 轉換成字符串 String.valueOf(char c) : 將 char 變量 c 轉換成字符串 String.valueOf(char[] data) : 將 char 數組 data 轉換成字符串 String.valueOf(char[] data, int offset, int count) : 將 char 數組 data 中 由 data[offset] 開始取 count 個元素 轉換成字符串 String.valueOf(double d) : 將 double 變量 d 轉換成字符串 String.valueOf(float f) : 將 float 變量 f 轉換成字符串 String.valueOf(int i) : 將 int 變量 i 轉換成字符串 String.valueOf(long l) : 將 long 變量 l 轉換成字符串 String.valueOf(Object obj) : 將 obj 對象轉換成 字符串, 等于 obj.toString() 用法如: int i = 10; String str = String.valueOf(i); 這時候 str 就會是 "10" 2. 由 String 轉換成 數字的基本數據型態 要將 String 轉換成基本數據型態轉 大多需要使用基本數據型態的包裝類別 比如說 String 轉換成 byte 可以使用 Byte.parseByte(String s) 這一類的方法如果無法將 s 分析 則會丟出 NumberFormatException byte : Byte.parseByte(String s) : 將 s 轉換成 byte Byte.parseByte(String s, int radix) : 以 radix 為基底 將 s 轉換為 byte 比如說 Byte.parseByte("11", 16) 會得到 17 double : Double.parseDouble(String s) : 將 s 轉換成 double float : Double.parseFloat(String s) : 將 s 轉換成 float int : Integer.parseInt(String s) : 將 s 轉換成 int long : Long.parseLong(String


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 焦作市| 墨竹工卡县| 上饶市| 莱阳市| 蒙山县| 南京市| 金山区| 来宾市| 阿尔山市| 玛多县| 鸡东县| 曲松县| 金坛市| 梁山县| 高密市| 东乌珠穆沁旗| 桃源县| 云林县| 隆昌县| 嘉禾县| 丹东市| 莎车县| 望城县| 兰溪市| 新巴尔虎左旗| 汨罗市| 沁水县| 芷江| 南充市| 石楼县| 云龙县| 邵东县| 定兴县| 梁山县| 荣昌县| 乌鲁木齐市| 什邡市| 剑河县| 华阴市| 中卫市| 纳雍县|