详细使用java八个包装类的方法和打印类变量

(1)char 2
(2)byte 1
(3)short 2
(4)int 4
(5)long 8
(6)float 4
(7)double 8
(8)boolean

(1)Character有个什么codePoint看不懂,码点??什么意思?
查了一些博客,
码点是指一个编码表中的某个字符对应的代码值,比如’\uFF21’这种格式或者数字,65,不是’A’;
大概懂的什么意思了,代码单元就是2个字节的char,而码点则是在一个字符使用4个字节的时候,也把它当成一个char,
所以如果使用了占用四个字节的char的时候,代码单元为2,因为一个java中char就是2字节,而计算码点(codePoint)就是1.

codePointOf(String),看不懂,网上也没找到
describeConstable(),有用到另一个Optional类,由于战略,先不练
digit(char, int): 对于数字的ascill从’0’到’9’,后面的radix要大于它就返回int数字,否则返回-1,对于字母,如果这个radix就变为,radix+‘A’/‘a’-10,如果小于,返回ch - ‘A’/‘a’+10,否则返回-1
digit(int,int)这个方法就是针对与码点的了,其他就没有什么差别了

继承来的方法,除非是重写,不然不会再方法表中
equals:这里的判断规则是,是Character或者char类型,然后值相等就好了,不需要是同一个对象

forDigit():是digit的相互转换的方法,digit返回的值,放到第一个参数,填上对应的radix,返回的值就是digit第一个参数的值

getDirectionality()返回的什么字符的方向性,看不懂,只知道会返回一个数字

getName();就是返回对应字符的描述
‘A’ = ‘\uFF21’
String name = Character.getName(‘A’);不一定需要码点值,用字符本身也可以

getNumaricValue(char c),返回的是 c-‘a’/‘A’ +10

getType()不知道这个返回的数字代表的类别是什么意思,大写字母是2,小写字母是1

hashCode() ,提供了类方法和实例方法,参数不同,所以算重载

highSurrogate(); 什么返回UTF-16,编码表示增补字符
增补字符:U+10000及以上的字符称为增补字符,还是不太懂

isAlphabetic()

isBmpCodePoint():BMP(基本多语言平面)是Unicode中的一个编码区段。编码从U+0000至U+FFFF。 Unicode 基本多文种平面的示意图。

isDefined()
isDigit()
isHighSurrogate() 传入Character.hignSurrogate(0x10123)返回true;
isIdentifierIgnorable();:确定是否应将指定字符视为 Java 标识符或 Unicode 标识符中的可忽略字符。,??java标识符也没有一个char的呀,还有可忽视字符又是什么,测试了一下‘\u0000’空格返回true

isIdeographic()
isISOControl()
isJavaIdentifierPart();
isJavaIdentifierStart(); //只要能用来当java标识符的第一个字符就返回true
isLetter()
isLetterOrDigit()
isLowerCase()

isLowSurrogate() ;和highSurrogate一样,没懂,传入Character.lowSurrogate(0x10123),返回true;

isMirrored();
isSpaceChar()
isSupplementaryCodePoint()

在java中打出char有如下三种方式
‘a’
‘\u1234’ 这里u后面只能四位
(char) 0x9999
最后这种可以用来打出增补字符,但是电脑上输出都是显示?因为无法显示,增补字符范围0x100000~0x10FFFF
\u后面的数字和0x后面的数字有一致性,也就是0x9999和’\u9999’输出一样

isSurrogate()
isSurrogatePair()

isTitleCase()
isUnicodeIdentifierPart()
isUnicodeIdentifierStart()
isUpperCase()
isValidCodePoint()
isWhitespace() s居然是小写

lowSurrogate()
offsetByCodePoints() 看不懂

reverseBytes()
toChars()
toCodePoint()
toLowerCase()
toString()
toTitleCase()
toUpperCase()
valueOf()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//从Character开始
		//Character还有很多类变量,但是很多看不懂,下面这几个还看的懂一点
		System.out.println(Character.BYTES+"");//Character在内存中的字节数
		System.out.println(Character.MAX_VALUE+"");//Character在最大值代表的字符
		System.out.println(Character.MIN_VALUE+"");//Character的最小的值代表的字符
		System.out.println(Character.SIZE+"");//Character在内存中的比特数
		//Character构造器只有一个,但是已经过时了,不再推荐使用实在要用,也可以用不过会警告
		char ch = new Character('c');//很诡异,我把一个char的直接量,包装成Charater类,然后赋值给一个char基本数据类型变量,
					//又自动拆箱成char
		showchar(ch);

		//Character方法
		int num = Character.charCount(150);//charCount返回需要几个字节才能表示这个字符,65535之前返回1,65536以及之后返回2
		System.out.println(num+"");
		System.out.println(0x11987);

		//Character.charValue(),返回Character对象的char值,也就是拆箱
		ch = new Character('u').charValue();
		showchar(ch);
		
		//codePointAt(),返回char数组中的某一个char的数字值
		num  = Character.codePointAt(new char[]{'c','a'},1,2);
		show(((char)num)+"");

		//codePointBefore(),返回index之前一个的char的数字值
		num = Character.codePointBefore(new char[]{'a','b','c'},1);
		show(((char)num)+"");

		//codePointCount() 
		String str = "𝕆";
		//num = Character.codePointCount(new char[]{'a','𝕆','c'},1,1);
		System.out.println("码点:"+str.codePointCount(0,str.length()));
		show("str的长度"+str.length()+"");
		//codePointOf
		//show("codePointOf:"+Character.codePointOf("utf-8"));

		//compare
		show(Character.compare('z','a')+"");

		//compareTo
		Character character = Character.valueOf('z');
		show(character.compareTo('a')+"");
		
		//digit
		num = Character.digit('4',5);
		show(num+"");
		num = Character.digit(65,20);
		show(num+"");

		//equals(),就是继承了Object的方法,好像是重写了,不然不会显示在那里,,对的
		character = new Character('a');
		Character character2 = new Character('a');
		show(character.equals(character2)+"");

		//forDigit
		ch = Character.forDigit(4,5);
		showchar(ch);
		show(ch+"");

		//getDirectionality()
		byte b = Character.getDirectionality('b');
		show(b+"");

		System.out.println(((char)'\u06ff')+"");

		//getName
		String name = Character.getName('b');
		System.out.println('b'+"");
		show(name);

		//getNumericValue()
		num = Character.getNumericValue('\uFF21');
		show(num+"");

		num = Character.getType('b');
		show(num+"");

		num = Character.hashCode('a');
		show(num+"");

		ch = Character.highSurrogate('\uFF21');
		show(ch+"");

		show(Character.isAlphabetic('A')+"");

		show(Character.isBmpCodePoint('A')+"");

		show(Character.isDefined('a')+"");
	
		show(Character.isDigit('9')+"");
		show(Character.isDigit('a')+"");

		show(Character.isHighSurrogate(Character.highSurrogate((char)0x10123))+"");
		show(Character.isHighSurrogate(Character.highSurrogate('\uadad'))+"");

		show(Character.isIdentifierIgnorable('\u0000')+"");

		show(Character.isIdeographic('\u9999')+"");
		
		show(Character.isISOControl('\u0022')+"");

		show(Character.isJavaIdentifierPart('1')+"");

		show(Character.isJavaIdentifierStart('1')+"");

		show(Character.isLetter('a')+"");	
		show(Character.isLetter('1')+"");

		show(Character.isLetterOrDigit('a')+"");
		show(Character.isLetterOrDigit('1')+"");

		show(Character.isLowerCase('1')+"");
		show(Character.isLowerCase('a')+"");
		show(Character.isLowerCase('A')+"");

		show(Character.isLowSurrogate((char)0x10123)+"");
		show(Character.isLowSurrogate('A')+"");

		show(Character.isMirrored('(')+"");
		show(Character.isMirrored('a')+"");

		show(Character.isSpaceChar(' ')+"");
		show(Character.isSpaceChar('a')+"");

		show(Character.isSupplementaryCodePoint(0x10123)+"");
		show(((char)0x10123)+"");
		show(((char)'\u9999')+"");
		
		show(Character.isSurrogate((char)0x10123)+"");
		show(Character.isSurrogatePair(Character.highSurrogate(0x10123) , Character.lowSurrogate(0x10123))+"");
		//show(Character.isHighSurrogate(Character.highSurrogate(0x10123))+"");

		
		show(Character.isTitleCase('A')+"");

		show(Character.isUnicodeIdentifierPart('a')+"");
		
		show(Character.isUnicodeIdentifierStart('a')+"");
		
		show(Character.isUpperCase('A')+"");
		show(Character.isUpperCase('a')+"");

		show(Character.isValidCodePoint('a')+"");

		show(Character.isWhitespace(' ')+"");
		show(Character.isWhitespace('a')+"");

		show(Character.lowSurrogate(0x10123)+"");

		num = Character.offsetByCodePoints(new char[]{'a','b','c'},0,2,1,1);
		show(num+"");
		
		show( Character.reverseBytes('a')+"");

		char[] chs = Character.toChars(0x9999);
		for( char c : chs)
		{
			System.out.println(c+"");
		}
		chs = new char[2];
		num = Character.toChars(0x10123,chs,0);
		for(char c:chs)
		{
			System.out.println(c+"");
		}
		num = Character.toCodePoint(Character.highSurrogate(0x10123), Character.lowSurrogate(0x10123));
		System.out.println(num+"");

		show(Character.valueOf('a').toString());

		show(Character.toString('a'));

		show(Character.isTitleCase(Character.toTitleCase('a'))+"");
		show(Character.toString(Character.toTitleCase('a'))+"");

		show(Character.toUpperCase('a')+"");

		show(Character.valueOf('a')+"");
		
		
		
		



	}
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


(2) byte
变量
BYTES
MAX_VALUE
MIN_VALUE
SIZE
TYPE
方法
byteValue()
compare()其实也就是相减
compareTo()
compareUnisigned() 会把计算机保存负数的补码直接转成数值,然后相减
也有一个describeConstable(),但是现在满知道有这么个东西就好了
doubleValue();
equals() 也是重写了,值相同就返回true
floatValue()
hashCode()
intValue()
longValue()
parseByte()
shortValue()
toString()
toUnsignedInt()
valueOf()

parseByte和valueOf中的radis,会把字符串按照对应进制解读成十进制值,如果这个十进制值超出byte的最大值或者小于最小值则会报错。
忘记把代码复制过来了,算了

short

由于自动转型,valueOf()可以使用(byte) 123
byteValue()
compare()
compareTo()
compareUnsigned()
decode()
describConstable()同样先放着
doubleValue()
equals()方法始终都是实例方法,因为Object里面equals就是实例方法,子类不能用类方法重写父类的实例方法
floatValue()
hashCode()
intValue()
longValue()
parseShort()
reverseBytes()
shortValue()
toString()
toUnsignedInt()
toUnsignedLong()
valueOf()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Short
		//类变量
		show(Short.BYTES+"");
		show(Short.MAX_VALUE+"");
		show(Short.MIN_VALUE+"");
		show(Short.SIZE+"");
		show(Short.TYPE+"");
		
		//构造器同样已经不推荐了,这里就不写了
		//方法
		Short sh = Short.valueOf("123");
		show(sh+"");
		byte by = sh.byteValue();
		show(by+"");

		show(Short.compare((short)11,(short) 55)+"");
		sh = Short.valueOf((byte)110);
		show(sh.compareTo((short)178)+"");

		show(Short.compareUnsigned((short)-100, (short) - 50)+"");
		
		short sho = Short.decode("1233");
		show(sho+"");
		
		double doub = Short.valueOf(sho).doubleValue();
		show(doub+"");

		sh = Short.valueOf("123");

		Object sh2 = Short.valueOf("123");
		show(sh.equals(sh2)+"");

		sh = Short.valueOf((short)111);
		show(sh.floatValue()+"");

		sh = Short.valueOf((short)55);
		show(sh.hashCode()+"");

		show(sh.intValue()+"");
		show(sh.longValue()+"");

		show(Short.parseShort("123")+"");
		show(Short.parseShort("123",16)+"");

		show(Short.reverseBytes((short)132)+"");

		show(sh.shortValue()+"");

		show(sh.toString());
		show(Short.toString((short)123));

		show(Short.toUnsignedInt((short)11)+"");
		show(Short.toUnsignedInt((short)-11)+"");

		show(Short.toUnsignedLong((short)12)+"");
		show(Short.toUnsignedLong((short)-12)+"");

		show(Short.valueOf((short)123)+"");
		show(Short.valueOf("123")+"");
		show(Short.valueOf("123",16)+"");

		

	}
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


decode()、parseShort()、valueOf()很相似

int
//类变量
BYTES
MAX_VALUE
MIN_VALUE
SIZE
TYPE
//方法
bitCount(int i ) 计算i的二进制中有几个1
byteValue()
compare()
compareTo()
compareUnsigned()(Character没有这个方法)
Integer的compare和compareTo还有compareUnsigned和Character、Byte、Short有所不同,Integer大于返回1,等于返回0 ,小于返回-1,而Character、Byte和Short对比返回的是二者的相减值

decode()
describeConstable()还是先放着
divideUnsigned()
doubleValue()
equals()
floatValue()
getInteger():这个方法比较奇怪,只能返回那个列表里面的整数,通过第一个参数的字符串,来获得对应的值,不过只有int类型的值才会返回,否则会返回默认值或者null
hashCode()
highestOneBit(),返回从右往左数,二进制中最后一个的1的对应的值
intValue()
longValue()
lowestOneBit()返回从右往左数,二进制中的第一个1的下标
max()
min()
numberOfLeadingZeros():返回从左往右数0的个数直到碰到第一个1后,停止
numberOfTrailingZeros():返回从左往右数最后一个1之后的0的个数
parseInt()
parseUnsignedInt():只能用来转换0和正数
remainderUnsigned()
resolveConstantDesc()涉及到了很多其他的类,先放着
reverse()
reverseBytes() : 总共四个字节,1、4交换,2、3交换
rotateLeft():将补码向左旋转 , 原本00001,rotateLeft(00001,1),后变成00010
rotateRight() : 将补码向右旋转,和上面类似,有点像循环左右移
shortValue()
signnum()
sum()
toBinaryString() = toString(xx,2)
toHexString() = toString(xx,16)
toOctalString() = toString(xx, 8)
toString()
toUnsignLong()
toUnsignString()
valueOf()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Integer
		//类变量
		show(Integer.BYTES+"");
		show(Integer.MAX_VALUE+"");
		show(Integer.MIN_VALUE+"");
		show(Integer.SIZE+"");
		show(Integer.TYPE+"");
		//构造器同样不推荐,这里不写了
		show(Integer.bitCount(2)+"");

		Integer integ = Integer.valueOf(2);
		Byte by = integ.byteValue();
		show(by+"");

		show(Integer.compare(100,10)+"");
		
		show(Integer.compareUnsigned(-10, 10)+"");

		show(Integer.decode("666")+"");

		show(Integer.divideUnsigned(200,-100)+"");

		integ = Integer.valueOf(155);
		show(integ.doubleValue()+"");

		show(integ.equals(155)+"");
		show(integ.equals(55)+"");

		show(integ.floatValue()+"");

		show(Integer.getInteger("java.specification.version",50)+"");
		
		show(integ.hashCode()+"");
		show(Integer.hashCode(integ)+"");

		show(Integer.highestOneBit(3)+"");

		show(integ.intValue()+"");
		show(integ.longValue()+"");

		show(Integer.lowestOneBit(3)+"");

		show(Integer.max(1,3)+"");
		show(Integer.min(1,3)+"");

		show(Integer.numberOfLeadingZeros(1)+"");
		show(Integer.numberOfLeadingZeros(2)+"");
		show(Integer.numberOfLeadingZeros(4)+"");

		show(Integer.numberOfTrailingZeros(1)+"");
		show(Integer.numberOfTrailingZeros(5)+"");

		CharSequence str = String.valueOf("12345");
		show(Integer.parseInt(str,1,3,10)+"");
		show(Integer.parseInt("123")+"");
		show(Integer.parseInt("a",16)+"");

		CharSequence cs = "-1111";
		show(Integer.parseUnsignedInt(cs,1,3,10)+"");
		show(Integer.parseUnsignedInt("15")+"");
		show(Integer.parseUnsignedInt("10",16)+"");

		show(Integer.remainderUnsigned(-5,-3)+"");
		
		show(Integer.reverse(2)+"");
		
		show(Integer.reverseBytes(2)+"");
		
		show(Integer.rotateLeft(1,2)+"");

		show(Integer.rotateRight(2,1)+"");

		Integer inte = Integer.valueOf(13);
		show(inte.shortValue()+"");

		show(Integer.signum(100)+"");
		show(Integer.signum(-23)+"");

		show(Integer.sum(10,10)+"");

		show(Integer.toBinaryString(3));

		//结合toBinaryString()和reverse
		show(Integer.toBinaryString(2));	
		show(Integer.toBinaryString(Integer.reverse(2)));

		//结合toBinaryString()和reverseBytes
		show(Integer.toBinaryString(256));
		show(Integer.toBinaryString(Integer.reverseBytes(256)));

		//结合toBinaryString()和rotateLeft
		show(Integer.toBinaryString(1));
		show(Integer.toBinaryString(Integer.rotateLeft(1,2)));

		//结合toBinaryString()和rotateRight
		show(Integer.toBinaryString(4));
		show(Integer.toBinaryString(Integer.rotateRight(4,2)));

		show(Integer.toHexString(10));
		show(Integer.toOctalString(8));

		inte = Integer.valueOf(10);
		show(inte.toString());

		show(Integer.toString(10));
		show(Integer.toString(8,2));

		show(Integer.toUnsignedLong(13)+"");
		
		show(Integer.toUnsignedString(10,16));

		show(Integer.valueOf(10)+"");
		show(Integer.valueOf("10")+"");
		show(Integer.valueOf("10",2)+"");
	}
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


40、使用Object的各种方法和查看各种变量

41、System.getProperty()使用

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		
		
		show(System.getProperty("java.version"));
		show(System.getProperty("java.version.date"));
		show(System.getProperty("java.vendor"));
		show(System.getProperty("java.vendor.url"));
		show(System.getProperty("java.vendor.version"));
		show(System.getProperty("java.home"));
		show(System.getProperty("java.vm.specification.version"));
		show(System.getProperty("java.vm.specification.vendor"));
		show(System.getProperty("java.vm.specification.name"));
		show(System.getProperty("java.vm.version"));
		show(System.getProperty("java.vm.vendor"));
		show(System.getProperty("java.vm.name"));
		show(System.getProperty("java.specification.version"));
		show(System.getProperty("java.specification.vendor"));
		show(System.getProperty("java.specification.name"));
		show(System.getProperty("java.class.version"));
		show(System.getProperty("java.class.path"));
		show(System.getProperty("java.library.path"));
		show(System.getProperty("java.io.tmpdir"));
		show(System.getProperty("java.compiler"));
		show(System.getProperty("os.name"));
		show(System.getProperty("os.arch"));
		show(System.getProperty("os.version"));
		show(System.getProperty("file.separator"));
		show(System.getProperty("path.separator"));
		show(System.getProperty("line.separator"));
		show(System.getProperty("user.name"));
		show(System.getProperty("user.home"));
		show(System.getProperty("user.dir"));

	}
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


long
类变量
BYTES
MAX_VALUE
MIN_VALUE
SIZE
TYPE
方法
bitCount()
compare()
compareTo()
compareUnsigned()
以上三个compare返回的也是-1,0,1,并不是char、byte、short返回的相减的值
decode()
describeConstable()先放着
divideUnsigned()
doubleValue()
equals()也是对象相同+值相同就返回true

getLong()应该和getInteger差不多吧,对,是差不多的
hashCode()
highestOneBit();返回最高一位1的值,0101,返回4,
intValue()
LongValue()
lowestOneBit():返回最低一位1的值,0100返回4
max()
min()
numberOfLeadingZeros()
numebrOfTrailingZeros()
parseLong()
parseUnsignedLong()
resolveConstantDesc()先放着
reverse()
reverseBytes() 1和8、2和7一次类推
rotateLeft()
rotateRight()
shortValue()
signum()
sum()
toBinaryString()
toHexString()
toOctalString()
toString()
toUnsignedString()
valueOf()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Long
		//类变量
		show(Long.BYTES+"");
		show(Long.MAX_VALUE+"");
		show(Long.MIN_VALUE+"");
		show(Long.SIZE+"");
		show(Long.TYPE+"");
		//构造器同样不推荐,这里不写了
		
		show(Long.bitCount(1)+"");

		Long lon = Long.valueOf(100);
		Byte by = lon.byteValue();
		show(by+"");

		show(Long.compare(100,200)+"");
		
		lon = Long.valueOf(200);
		show(lon.compareTo((long) 900)+"");
		show(Long.compareUnsigned(100,200)+"");

		show(Long.decode("10342")+"");

		show(Long.divideUnsigned(123,123)+"");

		lon = Long.valueOf(109);
		double dd = lon.doubleValue();
		show(dd+"");
		
		show(lon.equals((long)109)+"");
		show(lon.equals("109")+"");

		show(lon.floatValue()+"");

		show(Long.getLong("java.specification.version")+"");

		show(lon.hashCode()+"");

		show(Long.highestOneBit(5)+"");

		lon = Long.valueOf(123);
		show(lon.intValue()+"");
		show(lon.longValue()+"");
		
		show(Long.lowestOneBit(4)+"");
		show(Integer.lowestOneBit(4)+"");

		show(Long.max(323,888)+"");
		show(Long.min(323,888)+"");

		show(Long.numberOfLeadingZeros(1)+"");
		show(Long.numberOfTrailingZeros(1)+"");

		CharSequence ch = "123";
		show(Long.parseLong(ch,1,2,10)+"");
		show(Long.parseLong("123")+"");
		show(Long.parseLong("14",16)+"");
		show(Long.toHexString(14)+"");

		
		lon = Long.parseUnsignedLong("10");
		show(lon+"");
		show(Long.toBinaryString(lon));
	
		show(Long.parseUnsignedLong(ch,0,2,10)+"");
		show(Long.parseUnsignedLong("10",16)+"");

		show(Long.remainderUnsigned(-150,111)+"");
		show(Long.toBinaryString(-150)+"");
		
		show(Long.toBinaryString(10));
		show(Long.toBinaryString(Long.reverse(10)));
		show(Long.reverse(5)+"");

		show(Long.toBinaryString(256));
		show(Long.toBinaryString(Long.reverseBytes(256)));
		
		show(Long.toBinaryString(10));
		show(Long.toBinaryString(Long.rotateLeft(10,2)));
		show(Long.toBinaryString(Long.rotateRight(10,2)));

		lon = Long.parseLong("500");
		show(Long.toBinaryString(lon));
		show(lon.byteValue()+"");
		show(Integer.toBinaryString(lon.byteValue()));

		show(Long.signum(100)+"");
		show(Long.signum(-100)+"");
		
		show(Long.sum(10,10)+"");

		show(Long.toBinaryString(10));
		show(Long.toHexString(10));
		show(Long.toOctalString(10));

		show(lon.toString());
		show(Long.toString(10));
		show(Long.toString(10,8)+"");

		show(Long.toUnsignedString(10));
		show(Long.toUnsignedString(10,8));

		show(Long.valueOf(100)+"");
		show(Long.valueOf("100")+"");
		show(Long.valueOf("aaaa",16)+"");
	}
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


float
变量
BYTES
MAX_EXPONENT
MAX_VALUE
MIN_EXPONENT
MIN_VALUE 指数-149
MIN_NORMAL 指数-126
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY
SIZE
TYPE
方法
byteValue()
compare()
compareTo()
describeConstable()先放着
doubleValue
equals 重写过,类型相同,并且值相同,返回true
floatToIntBits()
在这里插入图片描述
好像是用来对特殊值进行比较的。
我懂了,直接把float的ieee754表达方式看出二进制,进行解读
floatToRawIntBits():这个方法只在NaN上和floatToIntBits()有区别,但是具体操作上,用Float.NaN传入后,输出并没与区别,根据老外的说法,是floatToIntBits()总是返回固定的标准格式,而FloatToRawIntBits()并不一定。暂时也只能这么理解了
在这里插入图片描述
floatValue()
hashCode() float这个方法就不是返回原值了,而且也不是floatToIntBits()返回的值

intBitsToFloat(),其实也就是floatToIntBits()的双向奔赴方法,把对应0x123456用ieee754方式解读

intValue()
isFinite()只有类方法
isInfinite()
isNaN()
longValue(),当浮点数为NaN的时候返回0,INFINITY都返回对应的long最大值和最小值
max()
min()
parseFloat()
resolveConstantDesc()先放着
shortValue(),会自动截断小数,不是四舍五入
sum()
toHexString()
toString() 并没有提供进制这个radix参数
valueOf() 也没有提供进制radix参数

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Float
		//类变量
		show(Float.BYTES+"");
		show(Float.MAX_EXPONENT+"");
		show(Float.MAX_VALUE+"");
		show(Float.MIN_EXPONENT+"");
		show(Float.MIN_NORMAL+"");
		show(Float.MIN_VALUE+"");
		show(Float.NaN+"");
		show(Float.NEGATIVE_INFINITY+"");
		show(Float.POSITIVE_INFINITY+"");
		show(Float.SIZE+"");
		show(Float.TYPE+"");
		//构造器同样不推荐,这里不写了

		Float fl = Float.valueOf(100);
		show(fl+"");
		show(fl.byteValue()+"");
		show(Float.compare(Float.valueOf(10),(float) 10.1)+"");
		
		fl = Float.valueOf(100);
		show(fl.doubleValue()+"");
		
		show(fl.equals(100)+"");
		show(fl.equals((float)100)+"");

		show(Float.floatToIntBits((float)2)+"");
		show(Integer.toBinaryString(Float.floatToIntBits((float)4)));
		show(Integer.toBinaryString((int)(float)4));

		show(Float.floatToIntBits(Float.NaN)+"");
		show(Integer.toBinaryString(Float.floatToIntBits(Float.NaN)));

		show(Float.floatToRawIntBits(Float.NaN)+"");
		show(Integer.toBinaryString(Float.floatToRawIntBits(Float.NaN)));

		//fl = Float.valueOf((float)6.6);
		show(fl.floatValue()+"");
		show(fl.hashCode()+"");

		show(Float.intBitsToFloat(0x7F800000)+"");
		//4的浮点数表达式的16进制是0x40800000
		show(Float.intBitsToFloat(0x40800000)+"");
		
		fl = Float.valueOf(10);
		show(fl.intValue()+"");
	
		show(Float.isFinite((float)10)+"");
		show(Float.isFinite((float)10.0/0)+"");

		show(Float.isInfinite(Float.POSITIVE_INFINITY)+"");
		show(Float.isInfinite((float)10)+"");
		fl = Float.POSITIVE_INFINITY;
		show(fl.isInfinite()+"");
		fl = Float.valueOf(10);
		show(fl.isInfinite()+"");

		fl = Float.valueOf(10);
		show(fl.isNaN()+"");
		show(Float.isNaN(fl)+"");
		fl = Float.NaN;
		show(fl.isNaN()+"");
		show(Float.isNaN(fl)+"");
	
		fl = Float.NEGATIVE_INFINITY;
		show(Long.MAX_VALUE+"");

		show(Float.max(10,20)+"");
		show(Float.min((float)10,(float)20)+"");

		show(Float.parseFloat("10.2")+"");
		fl = Float.parseFloat("10.8");
		show(fl.shortValue()+"");
		
		show(Float.sum((float)10.0,(float)20.0)+"");

		show(Float.toHexString(Float.NaN)+"");
		show(Float.toHexString(Float.NEGATIVE_INFINITY)+"");
		show(Float.toHexString((float)10.2));

		show(fl.toString());
		show(Float.toString((float)10.2));

		show(Float.valueOf("111.025")+"");
		show(Float.valueOf((float)111.025)+"");
		
	}	
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


double
变量
BYTES
MAX_EXPONENT
MAX_VALUE
MIN_EXPONENT
MIN_NORMAL
MIN_VALUE
NaN
NEGATIVE_INFINITY
POSITIVE_INFINITY
SIZE
TYPE
方法
valueOf()
compare()
compareTo()
以上两个compare也是-1,0,1
deacribeConstable() 先放着
doubleToLongBits()
doubleToRawLongBits()
doubleValue()
equals() 类型一样,值相同,true
hashCode() 返回的也不是原值,也不是doubleToLongBits()的返回值
intValue()
isFinite()对于Float的也有效,但是Float的isFinite不能传入Double的INFINITE
isInfinite()
isNaN()
longBitsToDouble()和doubleToLongBits()是双向奔赴方法
max()
min()
parseDouble()只能用String,很像是decode但是Double没有提供decode,Float也没有提供decode
resolveConstantDesc()先放着
shortValue()
sum()
toString();
toHexString()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Double
		//类变量
		show(Double.BYTES+"");
		show(Double.MAX_EXPONENT+"");
		show(Double.MAX_VALUE+"");
		show(Double.MIN_EXPONENT+"");
		show(Double.MIN_NORMAL+"");
		show(Double.MIN_VALUE+"");
		show(Double.NaN+"");
		show(Double.NEGATIVE_INFINITY+"");
		show(Double.POSITIVE_INFINITY+"");
		show(Double.SIZE+"");
		show(Double.TYPE+"");
		
		//构造器同样不推荐,这里不写了
		Double dou = Double.valueOf("10.3");
		dou = Double.valueOf(10.3);
		
		Byte bt = dou.byteValue();
		show(bt+"");
	
		show(Double.compare(10.5,5.5)+"");
		
		dou = Double.valueOf("10.5");
		show(dou.compareTo(5.5)+"");

		show(Double.doubleToLongBits(10.3)+"");
		show(Long.toBinaryString(Double.doubleToLongBits(10.3)));
		
		show(Double.NaN+"");
		show(Long.toBinaryString(Double.doubleToLongBits(10.3)));
		show(Long.toBinaryString(Double.doubleToRawLongBits(10.3)));

		double doub = Double.valueOf(103.8).doubleValue();
		show(doub+"");

		dou = 10.3;
		show(dou.equals(10.3)+"");
		show(dou.equals((float)10.3)+"");

		show(dou.floatValue()+"");

		show(dou.hashCode()+"");
		show(Double.doubleToLongBits(10.3)+"");

		show(dou.intValue()+"");

		show(Double.isFinite(10.2)+"");
		show(Double.isFinite(Double.POSITIVE_INFINITY)+"");
		show(Double.isFinite(Float.POSITIVE_INFINITY)+"");
		//show(Float.isFinite(Double.POSITIVE_INFINITY)+"");

		dou = Double.valueOf(10.336);
		show(dou.isInfinite()+"");
		show(Double.isInfinite(Double.POSITIVE_INFINITY)+"");

		dou = Double.NaN;
		show(dou.isNaN()+"");
		show(Double.isNaN(dou)+"");

		show(Double.longBitsToDouble(0x7ff0000_0000_0000_0L)+"");
	
		dou = Double.valueOf(10.6);
		show(dou.longValue()+"");
		show(Double.max(10.2,1.2)+"");
		show(Double.min(1.2,10.2)+"");

		show(Double.parseDouble("111.111")+"");

		show(dou.shortValue()+"");
		show(Double.sum(10.5,10.55)+"");
	
		show(dou.toString());
		show(Double.toString(55.5));
		
		show(Double.toHexString(8));
		

		

		
		
	}	
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


boolean
变量
FALSE
TRUE
TYPE
方法
valueOf()
booleanVlaue()
compare() -1,0,1
compareTo()
describeConstable()先放着
equals
getBoolean() 应该和getInteger()还有getLong()是一伙的
hashCode() true是1231 false是1237
logicalAnd()
logicalOr()
logicalXor()
parseBoolean() 除了true字符串,其他的值都会返回false
toString()

import static java.lang.System.*;

public class Test
{
	public static void main(String[] args)	
	{
		//Boolean
		//类变量
		show(Boolean.FALSE+"");
		show(Boolean.TRUE+"");
		show(Boolean.TYPE+"");
		//构造器同样不推荐,这里不写了
		
		//方法
		Boolean bool = Boolean.valueOf(true);
		bool = Boolean.valueOf("true");

		show(bool+"");

		show(bool.booleanValue()+"");

		show(Boolean.compare(true,false)+"");
		show(Boolean.compare(false,true)+"");
		show(Boolean.compare(true,true)+"");	
		show(Boolean.compare(false,false)+"");
		
		bool = Boolean.valueOf(false);
		Boolean bool2 = Boolean.valueOf("true");
		show(bool.compareTo(bool2)+"");

		show(bool.equals(false)+"");
		show(bool.equals(true)+"");
		show(bool.equals("哈哈")+"");

		bool = Boolean.valueOf(true);
		show(bool.hashCode()+"");
		show(Boolean.hashCode(bool)+"");
		bool = Boolean.valueOf(false);
		show(bool.hashCode()+"");
		show(Boolean.hashCode(bool)+"");

		show(Boolean.logicalAnd(true,true)+"");
		show(Boolean.logicalOr(true,true)+"");
		show(Boolean.logicalXor(true,true)+"");
		
		show(Boolean.parseBoolean("false")+"");
		show(Boolean.parseBoolean("yes")+"");

		bool = Boolean.valueOf("false");
		show(bool.toString());
		show(Boolean.toString(true));
	}	
	public static void showchar(char ch)
	{
		System.out.println(ch);
	}	
	public static void show(String info)
	{
		System.out.println(info);
	}

}


这些包装类,都说不能用于同步,否则会发生不可预测的后果
基本类型可以自动装拆箱成对应包装类,但是不同的基本类型和他们的包装类并不能自动转型,
基本数据类型,是可以自动转型成更大的基本数据类型,通过自动拆箱也可以实现包装类型的自动转型成更大的基本数据类型,
但是更小的包装类,不能自动转型成更大的包装类,更小的基本数据类型也就不能通过自动装箱变成更大的包装类
bit是比特,byte是字节

xxxValue(),超出了就会截断超过的部分,留下低位,如果最高位为1就当成负数补码,取反+1变成原码后,才是真值

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

细水长流cpu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值