http://904582819.blog.163.com/blog/static/11159282020127794456840/ equals方法和==的区别 首先大家知道,String既可以作为一个对象来使用,又可以作为一个基本类型来使用.这里指的作为一个基本类型来使用只是指使用方法上的,比如String s = "Hello",它的使用方法如同基本类型int一样,比如int i = 1;,而作为一个对象来使用,则是指通过new关键字来创建一个新对象,比如String s =…
Do NOT use the `==`` operator to test whether two strings are equal! It only determines whether or not the strings are stored in the same location. Sure, if strings are in the same location, they must be equal. But it is entirely possible to store mu…
一.先说说Java中equals和==的区别: Java中的数据类型,可分为两类: 1.基本数据类型(也叫原始数据类型) 八大基本数据类型 char byte short int long double float boolean 2.引用数据类型(也就复合数据类型)除了上面的8个,其他都是引用数据类型 区别: 基本数据类型比较只能用==,不能用equals,因为用equals(参数),参数必须为对象. 他们之间的比较,比较的是他们的值. public class Test { public s…