20165320 第六週學習總結

主要內容

string類

構造string對象
string s = new String("we are students");
string t = new String("we are students");]

用戶沒法輸出String對象的引用
能夠用已建立的String對象建立另外一個String對象

String常量的引用
字符串的並置

經常使用方法
public int length()獲取String對象的字符序列長度
public boolean equals(String s)比較對象的字符序列是否相同
public int compareTo(String s)字符序列比較大小

諸多類

Scanner類,StringTokenizer類,StringBuffer類,Date類,Calendar類,Math類,BigInteger類,Random類····

數字格式化

format方法,格式化整數,格式化浮點數

泛型

泛型類聲明
class People<E>;
使用泛型類聲明對象
Cone<Circle> coneOne;
coneOne = new Cone<Circle>(new Circle());

鏈表

鏈表能夠感受和C語言的鏈表有一些類似的地方
建立鏈表
LinkedList<String> mylist = new Linked List<String>();
經常使用方法
排序:public static sort(List<E> list) 按照升序排列
折半法:int binarySeach(List<T>list,T key,CompareTo<T> c) 查找有沒有和key相等的元素
洗牌與旋轉
public static void shuffle(List<E> list) 按洗牌算法從新隨機排列
static void romate(List<E> list,int distance) 旋轉表中的數據
public static void reverse(List<E> list) 翻轉表中的數據

代碼託管

碼雲連接:https://gitee.com/sq943997011/BESTI.IS.Java2018git

腳本運行截圖:
算法

相關文章
相關標籤/搜索