Java Collections

1. How to create generic array

  • List<Integer>[] array = new List[len];
  • import java.lang.reflect.Array;    ArrayList<Integer>[] array = (ArrayList<Integer>[])Array.newInstance(ArrayList.class, len);

 

2. Bit operations

  • Get the odd number that is larger or equal to itself
    • x | 1
  • Get the rightmost 1 of x
    • x & (-x)
  • Remove the last bit from x 
    • x & (x-1)
 
 
posted @ 2016-05-29 14:59  新一代的天皇巨星  阅读(150)  评论(0)    收藏  举报