//獲取鍵盤輸入 Scanner sc = new Scanner(System.in); int num = sc.nextIn(); String str = sc.nextLine();
全部類都直接或者間接繼承Object類java
public class Person{ } public class Test{ public static void main(string[] args){ Person p = new Person(); Person p1 = new Person(); system.out.printIn(p);//這裏打印的實際上是內存地址,默認調用了Object的toString()方法,能夠自定義 //equals默認比較的是兩個對象的內存地址,能夠自動生成比較 boolean result = p.equals(p1) //false } }
String s = String((String original);//字符串數據封裝成字符串對象 String s = String(char[] value);//字符串數組封裝爲字符串對象 String s = String(char[] value ,int index, int count);//字符串數 組的部分封裝爲字符串對象 String s1 = "he"; String s2 = new String("he");
StringBuilder S = new StringBuilder(); s.append("123");//添加 s.reverse();//反轉
//StringBuilder ----> String StringBuilder S = new StringBuilder(); String s1 = s.toString(); // String ----> StringBuilder StringBuilder s2 = new StringBuilder(s1)