Tristan_S 发表于 2013-2-1 11:20:06

常用技巧

集合和数组的转换
City[] cityArray = new City;cityList.toArray(cityArray);

char 转化 int
// char to intchar c = '3';   //int i = (int)c;//51int i = Integer.valueOf(String.valueOf(c));//3System.out.println(i);

随机排序
         Collections.shuffle(list); // 混乱的意思          System.out.println(list);

LinkedList类和ArrayList类

  在“集合框架”中有两种常规的 List 实现:ArrayList 和 LinkedList。使用两种 List 实现的哪一种取决于您特定的需要。如果要支持随机访问,而不必在除尾部的任何位置插入或除去元素,那么,ArrayList 提供了可选的集合。但如果,您要频繁的从列表的中间位置添加和除去元素,而只要顺序的访问列表元素,那么,LinkedList 实现更好。

有时eclipse的format不是我们想要的, 比如不希望format JavaDoc 中的信息

http://dl.iteye.com/upload/attachment/482900/9979325b-2dcb-31b0-b1a5-468fd32ad9a7.jpg


动态规划, 贪心算法, 最小生成树


生成[1,2.5)区间的小数
double d3 = r.nextDouble() * 1.5 + 1;
页: [1]
查看完整版本: 常用技巧