内容简介:String小结
String应该是用得最多的一个类型,不管是之前使用了无数次也好,又不管是看过源码也好,还是有些坑要注意
总结
String#getBytes()
getBytes得到的是地址,所以对同一个Stirng调用getBytes得到的内容是不同的
@Test
public void getBytesTest(){
String s = "123456";
System.out.println(s.getBytes()); //[B@61e717c2
System.out.println(s.getBytes()); //[B@66cd51c3
System.out.println(s.getBytes()); //[B@4dcbadb4
}
String#equals()
虽然String的equals()接受的是Object对象,但是如果想要返回true,传入的也必须是equals对象,同理,Integer之类也有类似情况
@Test
public void equalsTest(){
String str = "1234";
Integer integer = 1234;
System.out.println(str.equals(integer));//false
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Pattern Recognition and Machine Learning
Christopher Bishop / Springer / 2007-10-1 / USD 94.95
The dramatic growth in practical applications for machine learning over the last ten years has been accompanied by many important developments in the underlying algorithms and techniques. For example,......一起来看看 《Pattern Recognition and Machine Learning》 这本书的介绍吧!
在线进制转换器
各进制数互转换器
HSV CMYK 转换工具
HSV CMYK互换工具