這里有我之前上課總結的一些知識點以及代碼大部分是老師講的筆記 個人認為是非常好的,,也是比較經典的內容,真誠的希望這些對于那些想學習的人有所幫助!
由于代碼是分模塊的上傳非常的不便。也比較多,講的也是比較清晰的!如果你有需要可以在評論中留下您的郵箱我看到一定會免費發給你的!感謝這個平臺讓我們大家共同進步吧!! 記住 程序員是無私的!!!
也非常歡迎到我的博客內觀看 博客地址:http://m.survivalescaperooms.com/duscl/
/*2:API的概述(了解) (1)應用程序編程接口。 (2)就是JDK提供給我們的一些提高編程效率的java類。3:Object類(掌握) (1)Object是類層次結構的根類,所有的類都直接或者間接的繼承自Object類。 (2)Object類的構造方法有一個,并且是無參構造 這其實就是理解當時我們說過,子類構造方法默認訪問父類的構造是無參構造 (3)要掌握的方法: A:toString() 返回對象的字符串表示,默認是由類的全路徑+'@'+哈希值的十六進制表示。 這個表示其實是沒有意義的,一般子類都會重寫該方法。 如何重寫呢?過程我也講解過了,基本上就是要求信息簡單明了。 但是最終還是自動生成。 B:equals() 比較兩個對象是否相同。默認情況下,比較的是地址值是否相同。 而比較地址值是沒有意義的,所以,一般子類也會重寫該方法。 重寫過程,我也詳細的講解和分析了。 但是最終還是自動生成。 (4)要了解的方法: A:hashCode() 返回對象的哈希值。不是實際地址值,可以理解為地址值。 B:getClass() 返回對象的字節碼文件對象,反射中我們會詳細講解 C:finalize() 用于垃圾回收,在不確定的時間 D:clone() 可以實現對象的克隆,包括成員變量的數據復制,但是它和兩個引用指向同一個對象是有區別的。 (5)兩個注意問題; A:直接輸出一個對象名稱,其實默認調用了該對象的toString()方法。 B:面試題 ==和equals()的區別? A:== 基本類型:比較的是值是否相同 引用類型:比較的是地址值是否相同 B:equals() 只能比較引用類型。默認情況下,比較的是地址值是否相同。 但是,我們可以根據自己的需要重寫該方法。1:Scanner的使用(了解) (1)在JDK5以后出現的用于鍵盤錄入數據的類。 (2)構造方法: A:講解了System.in這個東西。 它其實是標準的輸入流,對應于鍵盤錄入 B:構造方法 InputStream is = System.in; Scanner(InputStream is) C:常用的格式 Scanner sc = new Scanner(System.in); (3)基本方法格式: A:hasNextXxx() 判斷是否是某種類型的 B:nextXxx() 返回某種類型的元素 (4)要掌握的兩個方法 A:public int nextInt() B:public String nextLine() (5)需要注意的小問題 A:同一個Scanner對象,先獲取數值,再獲取字符串會出現一個小問題。 B:解決方案: a:重新定義一個Scanner對象 b:把所有的數據都用字符串獲取,然后再進行相應的轉換 2:String類的概述和使用(掌握) (1)多個字符組成的一串數據。 其實它可以和字符數組進行相互轉換。 (2)構造方法: A:public String() B:public String(byte[] bytes) C:public String(byte[] bytes,int offset,int length) D:public String(char[] value) E:public String(char[] value,int offset,int count) F:public String(String original) 下面的這一個雖然不是構造方法,但是結果也是一個字符串對象 G:String s = "hello"; (3)字符串的特點 A:字符串一旦被賦值,就不能改變。 注意:這里指的是字符串的內容不能改變,而不是引用不能改變。 B:字面值作為字符串對象和通過構造方法創建對象的不同 String s = new String("hello");和String s = "hello"的區別? (4)字符串的面試題(看程序寫結果) A:==和equals() String s1 = new String("hello"); String s2 = new String("hello"); System.out.PRintln(s1 == s2);// false System.out.println(s1.equals(s2));// true String s3 = new String("hello"); String s4 = "hello"; System.out.println(s3 == s4);// false System.out.println(s3.equals(s4));// true String s5 = "hello"; String s6 = "hello"; System.out.println(s5 == s6);// true System.out.println(s5.equals(s6));// true B:字符串的拼接 String s1 = "hello"; String s2 = "world"; String s3 = "helloworld"; System.out.println(s3 == s1 + s2);// false System.out.println(s3.equals((s1 + s2)));// true System.out.println(s3 == "hello" + "world");// false 這個我們錯了,應該是true System.out.println(s3.equals("hello" + "world"));// true (5)字符串的功能(自己補齊方法中文意思) A:判斷功能 boolean equals(Object obj) boolean equalsIgnoreCase(String str) boolean contains(String str) boolean startsWith(String str) boolean endsWith(String str) boolean isEmpty() B:獲取功能 int length() char charAt(int index) int indexOf(int ch) int indexOf(String str) int indexOf(int ch,int fromIndex) int indexOf(String str,int fromIndex) String substring(int start) String substring(int start,int end) C:轉換功能 byte[] getBytes() char[] toCharArray() static String valueOf(char[] chs) static String valueOf(int i) String toLowerCase() String toUpperCase() String concat(String str) D:其他功能 a:替換功能 String replace(char old,char new) String replace(String old,String new) b:去空格功能 String trim() c:按字典比較功能 int compareTo(String str) int compareToIgnoreCase(String str) (6)字符串的案例 A:模擬用戶登錄 B:字符串遍歷 C:統計字符串中大寫,小寫及數字字符的個數 D:把字符串的首字母轉成大寫,其他小寫 E:把int數組拼接成一個指定格式的字符串 F:字符串反轉 G:統計大串中小串出現的次數*/
新聞熱點
疑難解答