1、相等性的比较
1)原生数据:值
2)引用类型:指向同一地址/引用地址
2、java.lang.Object类
java.lang包使用时无需显式导入
3、API:Application Programming Interface
4、打印引用时,打印的是引用所指对象的toString()方法的返回值。因为每个类都直接或间接地继承自Object,而Object类中定义了toString(),因此每个类都有toString()这个方法。
public class ObjectTest
{
public static void main(String[] args)
{
Object object = new Object();
System.out.println(object);
System.out.println(object.toString());
String str = "aaa";
System.out.println(str);
System.out.println(str.toString());
Student student = new Student();
System.out.println(student);
System.out.println(student.toString());
}
}
class Student extends Object
{
public String toString()
{
return "Hello World";
}
}
5、关于进制:
十六进制用 0-9 a、b、c、d、e、f 表示
例:十六进制的123 转化为十进制 即为:116^2+2161+3*160
6、
public class ObjectTest2
{
public static void main(String[] args)
{
Object object = new Object();
Object object2 = new Object();
System.out.println(object == object2);//false
System.out.println("---------------");
String str = new String("aaa");
String str2 = new String("aaa");
System.out.println(str == str2);//false
System.out.println("---------------");
String str3 = "bbb";
String str4 = "bbb";
System.out.println(str3 == str4);//true
System.out.println("---------------");
String str5 = new String("ccc");
String str6 = "ccc";
System.out.println(str5 == str6);//false
System.out.println("---------------");
String s = "hello";
String s1 = "hel";
String s2 = "lo";
System.out.println(s == s1 + s2);//false
System.out.println("---------------");
System.out.println(s == "heo" + "lo");//true
}
}