直接来码
package com.String;
public class ByteDamo {
static void m1() {
//byte 的构造函数
Byte bb=new Byte((byte) 333);
System.out.println(bb);
Byte jByte=new Byte("33");
System.out.println(jByte);
}
public static void main(String[] args) {
//m1();
Byte ll=new Byte((byte) 4.56);
//byteValue() 返回此值 Double为 byte的基本收缩转换后。
System.out.println(ll.byteValue());//该对象在转换为 byte后转换的 byte 。
//compare(byte x, byte y) 数值比较两个 byte值。
Byte kk=new Byte((byte) 20);
Byte kk1=new Byte((byte) 80);
System.out.println(new Byte((byte) 3).compare(kk, kk1));//返回的值为kk-kk1
//compareTo(Byte anotherByte) 数字比较两个 Byte对象。
Byte qq = 10;
Byte ww=3;
System.out.println(qq.compareTo(qq));//返回的值为ww-qq;
System.out.println(ww.compareTo(qq));
//decode(String nm) 将 String解码成 Byte 。
Byte kk2=new Byte("5");
System.out.println(kk2.decode("9"));//一个 Byte对象持有 byte值代表 nm
//doubleValue() 返回此值 Byte为 double一个宽元转换后。
System.out.println(new Byte("23").doubleValue());//此对象在转换为 double之后表示的 double 。
//equals(Object obj) 将此对象与指定的对象进行比较。
System.out.println(new Byte("22").equals(2));//返回值为true和false
//floatValue() 返回此值 Byte为 float一个宽元转换后。
System.out.println(new Byte("56").floatValue());//返回值为float
//hashCode() 返回这个Byte的哈希码; 等于调用intValue()的结果。
System.out.println(new Byte("50").hashCode());
System.out.println(new Byte("5").hashCode());
//hashCode(byte value) 返回一个byte值的哈希码; 兼容Byte.hashCode() 。
System.out.println(new Byte("12").hashCode(new Byte((byte) 2)));
//intValue() 返回此的值 Byte作为 int加宽原始转换之后。
System.out.println(new Byte("2").intValue());
System.out.println(new Byte("-5").intValue());
//longValue() 返回此值 Byte为 long一个宽元转换后。
System.out.println(new Byte("56").longValue());//返回的值为Long型
//parseByte(String s) 将字符串参数解析为带符号的十进制 byte 。
System.out.println(new Byte("45").parseByte("2"));
System.out.println(new Byte("45").parseByte("10"));//全部以十进制返回
System.out.println(new Byte("45").parseByte("-3"));
//parseByte(String s, int radix) 将字符串参数解析为第二个参数指定的基数中的带符号的 byte 。
System.out.println(new Byte((byte) 22).parseByte("11", 3));//表示 字符串11以3为基数表示为10进制的byte值是 4 ,这里的11表示的是一个3进制数
//如果你给的string 不能转换,或者基数小于2或大于36 会抛出异常
System.out.println(new Byte("23").parseByte("11", 4));
System.out.println(Byte.parseByte("1", 2));
//shortValue() 返回此值 Byte为 short一个宽元转换后。
System.out.println(new Byte("1").shortValue());//返回的类型为short
//toString(byte b) 返回一个新的 String对象,代表指定的 byte 。
System.out.println(new Byte("45").toString(new Byte((byte) 23)));
//valueOf(byte b) 返回一个 Byte指定的 byte值的 Byte实例。
System.out.println(new Byte("12").valueOf(new Byte((byte) 6)));
//valueOf(String s) 返回一个 Byte物体保持由指定的给定的值 String 。
System.out.println(new Byte((byte) 32).valueOf("-23"));//返回一个Byte物体保持由指定的给定的值String 。 该参数被解释为表示一个有符号的十进制byte ,
//valueOf(String s, int radix)
//返回一个 Byte对象,该对象保存从指定的String中 String的值,并使用第二个参数给出的基数进行解析。
System.out.println(new Byte("23").valueOf("56", 8));//返回八进制的56
}
}