java Short详解

package com.String;

public class ShorDamo {
	static void m1() {
		Short short1=new Short((short) 23);
		Short short2=new Short("12");
		System.out.println(short1);
		System.out.println(short2);
	}
	public static void main(String[] args) {
		m1();
		
		//byteValue() 返回此值 Short为 byte的基本收缩转换后。
		Short short1=new Short((short) 23);
		System.out.println(short1.byteValue());
		
		//compareTo(Short anotherShort) 以数字比较两个 Short对象。 
		System.out.println(short1.compareTo(new Short((short) 12)));
		System.out.println(short1.compareTo(new Short((short) 24)));//short1-short2
		System.out.println(short1.compareTo(new Short((short) 0)));
		
		//decode(String nm) 将 String解码为 Short 。 
		System.out.println(short1.decode("12"));
		System.out.println(short1.decode("-12"));
		
		//doubleValue() 返回此值 Short为 double一个宽元转换后。 
		System.out.println(short1.doubleValue());
		
		//floatValue() 	在扩展原始转换后,以 float形式返回此 Short的值。 
		System.out.println(short1.floatValue());
		
		//hashCode() 返回这个Short的哈希码; 等于调用intValue()的结果。 
		System.out.println(short1.hashCode());
		
		//hashCode(short value) 返回一个short值的哈希码; 兼容Short.hashCode() 。 
		System.out.println(short1.hashCode(new Short((short) 12)));
		
		//intValue() 返回此的值 Short作为 int加宽原始转换之后。 
		System.out.println(short1.intValue());
		
		//longValue() 返回此值 Short为 long一个宽元转换后。 
		System.out.println(short1.longValue());
		
		//parseShort(String s) 将字符串参数解析为带符号的十进制 short 。
		System.out.println(short1.parseShort("12"));
		
		//reverseBytes(short i) 返回反转指定的二进制补码表示的字节顺序而获得的值 short值。
		System.out.println(short1.reverseBytes(new Short((short) 33)));
		
		//shortValue() 将此 Short的值作为 short 
		System.out.println(short1.shortValue());
		
		//toUnsignedInt(short x) 的参数的转换 int由无符号转换。 
		System.out.println(short1.toUnsignedInt(new Short((short) 3)));
		
		//valueOf(String s) 返回一个 Short物体保持由指定的给定的值 String 。 
		System.out.println(short1.valueOf("11"));
		
		
		 
		 
		
		
		
		
	
		
		
		
		
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值