20165310java_blog_week6
2165310 《Java程序設計》第6周學習總結(jié)
教材學習內(nèi)容總結(jié)
String
- 構造
- String str=new String()
- String (char a[])
- String (char a[],int startIndex,int count)
- 并置
- 常量的并置是常量(可以用==進行比較)
- 變量的并置是新對象(不能用==只能用equals()進行比較
- 常用方法
- public int length():獲得String對象的字符序列長度。
- public boolean equals(String s) :比較字符序列是否相同。
- 比較
- public boolean startsWith(String s):比較字符序列前綴是否為指定字符序列。
- public boolean endsWith(String s):比較字符序列后綴是否為指定字符序列。
- public int compareTo(String s):按字典序列與指定字符序列s比較大小。
- 索引
- public boolean contains(String s):判斷是否包含指定 字符序列
- public int indexOf(String s):返回s首次出現(xiàn)的位置
- public int lastIndexOf(String s):返回s最后出現(xiàn)的位置
- public int indexOf(String s,int startpoint):返回指定索引開始位置之后的,s首次出現(xiàn)的位置
- 從String獲得String新對象
- public String substring(int startpoint):返回復制指定位置到最后位置的字符序列所得到的新序列
- public String substring(int start,int end):返回復制指定開始位置到指定結(jié)束位置的字符序列所得到的新序列
- 基本數(shù)據(jù)類型轉(zhuǎn)化為String類:public static String valueOf(<基本數(shù)據(jù)類型> n)
- String類型轉(zhuǎn)化為基本數(shù)據(jù)類型:<基本數(shù)據(jù)類型> n=<相應類>.parse<相應數(shù)據(jù)類型>(s)
- 字符串轉(zhuǎn)化為字符數(shù)組
- public void getChars(int start,int end,char c[],int offset):從數(shù)組C的offset處存放String類字符序列sart到end-1處的字符。
- public char[] toCharArray():返回一個長度相等的數(shù)組。
- public String repalceAll(String regex,String replacement):用replacement字符序列替換regex匹配的序列。
public String[] split(Sring regex):存放按照regex分割的單詞在String數(shù)組中。(注意前綴是否匹配影響數(shù)組存放)
StringBuff
- StringBuff()
- StringBuff(int size)
- StringBuff(String s)
- length():獲取字符序列長度
- capacity():獲得實體容量
- append方法
- StringBuff append(String s):追加s到StringBuff中。
- StringBuff append(int n):n轉(zhuǎn)化為String類,追加到StringBuff中。
- StringBuff append(Object o):追加o的字符序列表示到StringBuff中。
StringBuff replace(int startIndex,int endIndex,String str):用str替換startIndex到endIndex-1處的字符序列。
分解字符序列
- 構造方法:
- StringTokenizer(String s):默認分隔標記分析s。
- StringTokenizer(String s,String delim):指定分隔標記delim分析s。
- 構造方法:Scanner scanner=new Scanner(str)
- 常用方法
- useDelimiter(正則表達式):利用正則表達式解析str。
- hasnext():判斷最后一個單詞是否被返回。
- next():依次返回單詞。
nextInt()或者nextDouble:依次返回單詞并進行類型轉(zhuǎn)換為int或者double型。
正則表達式:
在假期實驗樓學習和書本p186到188中都有,已經(jīng)整理過不多加贅述。
Random
- public Random()
- public Random(seed)
- nextInt(int n):返回0-n之間的某個整數(shù)。
- nextDouble():返回0-1.0之間的隨機數(shù)。
- nextDouble():返回0-1.0之間的隨機數(shù)。
nextBoolean():隨機返回true或者false。
Console
- 引入java.io包
- Console cons=System.comsole()
char[] passwd=cons.readPasswoerd()
泛型
聲明對象:同樣多加一個
鏈表
- public boolean add(E element):鏈表末尾添加數(shù)據(jù)為element的新結(jié)點。
- public boolean add(int index,E element):鏈表指定位置添加數(shù)據(jù)為element的新結(jié)點。
- public boolean clear():刪除鏈表所有結(jié)點,使成為空鏈表。
- public boolean remove(E element):刪除鏈表首次出現(xiàn)element的結(jié)點。
- public E remove(int index):刪除指定位置結(jié)點。
- public int indexOf(E element):返回首次出現(xiàn)element的位置,沒有返回-1。
- public int lastIndexOf(E element):返回最后出現(xiàn)element的位置,沒有返回-1。
- public E set(int index,E element):替換index位置結(jié)點數(shù)據(jù)為element。
- public int size():返回鏈表長度,即結(jié)點個數(shù)。
- public boolean contains(Object element):判斷是否有結(jié)點數(shù)據(jù)為element。
- public boolean addFirst(E element):鏈表頭添加數(shù)據(jù)為element的新結(jié)點。
- public boolean addLast(E element):鏈表末尾添加數(shù)據(jù)為element的新結(jié)點。
- public E getFirst:得到第一個結(jié)點中的數(shù)據(jù)。
- public E getLast:得到最后結(jié)點中的數(shù)據(jù)。
- public E removeFirst(int index):刪除第一個結(jié)點,并返回這個結(jié)點數(shù)據(jù)。
- public E removeLast(int index):刪除最后一個結(jié)點,并返回這個結(jié)點數(shù)據(jù)。
- public Object clone():得到一個克隆列表。
- 構造: Iterator <String> iter=list.iterator()
- iter.hasNext()
- iter.next()
- public static sort(List<E>list):元素升序排列
- int binarySearch(List<T>list,T key,CompareTo<T> c):折半查找是否含有參數(shù)key
- public static void shuffle<List<E> list):洗牌
- static void rotate(List<E> list,int distance):旋轉(zhuǎn)
`public static void reserve<List<E> list):翻轉(zhuǎn)
堆棧
返回數(shù)據(jù)索引:public int search(Object data)
散列映射
- public void clear():清空
- public Object clone():返回當前散列映射的一個克隆
- public boolean containsKey(Object key):判斷是否有鍵/值對使用了參數(shù)指定的鍵
- public boolean containsValue(Object value):判斷是否有鍵/值對使用了參數(shù)指定的值
- public V get(Object key):返回用key做鍵的鍵/值對中的值
- public boolean isEmpty():判斷是否不含任何鍵/值對
- public V remove(Object key):刪除key做鍵的鍵/值對,返回對應的值
public int size():返回散列映射大小,即鍵/值對數(shù)目
樹集
- public boolean add(E o):添加結(jié)點,數(shù)據(jù)為參數(shù)o
- public void clear():刪除所有結(jié)點
- public void contains(Object o):判斷是否包含指定參數(shù)的對象
- public E first():返回第一個結(jié)點中的數(shù)據(jù)
- public E last():返回最后一個結(jié)點中的數(shù)據(jù)
- public boolean isEmpty():判斷是否空集
- public boolean remove(Object key):刪除存儲指定參數(shù)的最小結(jié)點
- public int size()`:返回結(jié)點數(shù)目
TreeMap<K,V,>
教材學習中的問題和解決過程
解決過程:和結(jié)對學習的小組成員共同討論,查找,發(fā)現(xiàn)問題后改正。
代碼托管
上周考試錯題總結(jié)
測試完成后補充
轉(zhuǎn)載于:https://www.cnblogs.com/atbaoi/p/8747572.html
總結(jié)
以上是生活随笔為你收集整理的20165310java_blog_week6的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Pycharm软件注册方法
- 下一篇: ACM数论之旅2---快速幂,快速求a^