Java Integer decode()方法具有什么功能呢?
下文笔者将讲述 java.lang.Integer decode()方法的功能简介说明,如下所示:
将一个字符串解码为一个int值
java.lang.Integer decode()的功能
java.lang.Integer.decode()的功能:将一个字符串解码为一个int值
注意事项:
1.此方法是一个静态方法
2.字符串可以为十进制,十六进制,八进制
java.lang.Integer.decode()的语法
语法 public static Integer decode(String nm) throws NumberFormatException 参数 nm:待解码的字符串 返回值 返回解码后的Integer对象例:
package com.java.other;
import org.junit.Test;
public class other {
/**
* java265.com Integer类的示例分享
*
* @throws Exception
*/
@Test
public void test() throws Exception {
String s1 = "0x81";
String s2 = "99";
System.out.println(Integer.decode(s1));
System.out.println(Integer.decode(s2));
}
}
------运行以上代码,将输出以下信息-----
129
99
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


