字符串charAt,indexOf,startsWith,endsWith,matches,StringBuffer的reverse().toString(),Character 的isLowerCase, toUpperCase, map的containsKey( ),size(),keySet();

一、字符串

字符串charAt,indexOf,startsWith,endsWith,matches,split

String[] arr = str.split(",");

二、数组

Integer[] arr = {1,3,5,2,4,6};

//默认升序

Arrays.sort(arr);

//实现降序

Arrays.sort(arr, new Comparator<Integer>(){

  public int compare(Integer A, Integer B){

    return B-A;

  }

})

三、StringBuffer

String reverse = stringbuffer.reverse().toString();

四、Character

Character 的isLowerCase, toUpperCase

五、list

Collections.sort(list);

Collections.sort(list, new Comparator<Interval>(){

  public int compare(Interval A, Interval B){

    if(A.start!=B.start){

      return (A.start-B.start);

    }else{

      return (A.end-B.end);

    }
  }

})

Collections.reverse(list);

六、map

Map<Integer,Integer> map = new HashMap<Integer, Integer>();

map.put(1,1);

map.put(2,2);

map.put(3,3);

map.size();

map.contiansKey(1);

for(Integer tmp: map.keySet){

  Integer v = map.get(tmp);

}

 

posted @ 2022-11-13 10:14  northli  阅读(10)  评论(0编辑  收藏  举报