筆試:一些怕忘掉的基礎東西

平方函數:Math.pow(a,b)

new一個數組:

int[] index=new int[3];//已知容量
int[] index={2,3,4};//已知數據

int[][] index2=new int[2][3];//二維數組
 

new一個arraylist

        List<String> list=new ArrayList<>();
        List<HashSet<String>> list1=new ArrayList<>();

int-字符串互轉

        Integer.parseInt("2");
        System.out.println(String.valueOf(2));

數組-list互轉

list轉爲數組:toarray方法

 

 這樣使用纔是帶泛型的

 

 

 

排序,反轉,二分查找

Arrays和Collections工具類中的方法

 

字符串和字符數組轉換

char[] charArray=ass.toCharArray();

 

棧和隊列這兩種數據結構

棧:後進先出

隊列:先進先出

        Queue<String> queue=new LinkedList<>();
        queue.add("2");
        queue.poll();
Stack<String> strings=new Stack<>();
strings.push("")
strings.pop();
 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章