Java Byte类之decode()方法的功能说明
下文笔者将讲述Java.lang.Byte类中decode()方法的功能简介说明,如下所示:
decode()方法的功能
java.lang.Byte.decode()的功能:将字符串(十进制、十六禁止)转换为字节(八进制数)
decode语法
decode语法 public static Byte decode(String nm)throws NumberFormatException 参数 nm:待解码的字符串 返回值 返回相应的字节值例:
package com.java265.other;
import org.junit.Test;
public class other {
/**
* java265.com 测试示例分享
*/
@Test
public void test() {
/**
* Byte类 decode方法的示例
*/
Byte b1 = Byte.decode("88");
Byte b4 = Byte.decode("061");
Byte b2 = Byte.decode("0x3c");
Byte b3 = Byte.decode("-#3c");
System.out.println(b1);
System.out.println(b2);
System.out.println(b3);
System.out.println(b4);
}
}
--------运行以上代码,将输出以下信息----
88
60
-60
49
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。


