1、相等性的比較
1)原生數(shù)據(jù):值
2)引用類型:指向同一地址/引用地址
2、java.lang.Object類
java.lang包使用時(shí)無(wú)需顯式導(dǎo)入
3、API:Application Programming Interface
4、打印引用時(shí),打印的是引用所指對(duì)象的toString()方法的返回值。因?yàn)槊總€(gè)類都直接或間接地繼承自O(shè)bject,而Object類中定義了toString(),因此每個(gè)類都有toString()這個(gè)方法。
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、關(guān)于進(jìn)制:
十六進(jìn)制用 0-9 a、b、c、d、e、f 表示
例:十六進(jìn)制的123 轉(zhuǎn)化為十進(jìn)制 即為: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
}
}