Java 基础
黑铁程序yuan
Your persistence will reward you .
展开
-
插入操作 LinkedList 一定比 ArrayList 高效吗?
参考文献Java 程序员,别用 Stack?!实例演示public static void main(String[] args) { List<Integer> list1 = new ArrayList<>(); List<Integer> list2 = new LinkedList<>(); long start = System.currentTimeMillis(); f原创 2020-09-12 15:00:15 · 149 阅读 · 0 评论 -
HashMap 线程不安全的例子
public static void main(String[] args) throws InterruptedException {// Map<Integer, Integer> map = new HashMap<>(); Map<Integer, Integer> map = new ConcurrentHashMap<>(); CountDownLatch countDownLatch = new原创 2020-08-16 10:37:31 · 684 阅读 · 0 评论 -
java容器
文章目录1.概览2.List2.1 ArrayList(✔)2.2 LinkedList(✔)2.3 Vector(✔)2.4 CopyOnWriteArrayList(✔)3.Map3.1 HashMap3.2 LinkedHashMap(✔)3.3 WeakHashMap(✔)3.4 TreeMap3.5 ConcurrentHashMap(✔)3.6 ConcurrentSkipListMap4. Set4.1 HashSet4.2 LinkedHashSet4.3 TreeSet4.4 CopyOn原创 2020-07-22 13:35:33 · 168 阅读 · 0 评论 -
java基础常见问题总结_不断完善
文章目录1. Integer vs int2. 关键字3.String4. 参数传递5. 类型转换6. switch7. 抽象类和接口8. 重写 vs 重载9. Object10. 反射11. 异常12.注解13. 新特性1. Integer vs int范围 -2^31 ~ 2^31-1装箱(自动调用valueOf)/拆箱new Integer(123) Integer.valueOf(123)private static class IntegerCache sta原创 2020-07-15 14:51:24 · 169 阅读 · 0 评论 -
Java 异常处理最佳实践
文章目录1.来源2.一般规范3.实例说明3.1 Example1.java3.2 Example2.java3.3 Example3.java3.4 Example4.java3.5 Example5.java3.6 Example6.java3.7 Example7.java3.8 Example8.java3.9 Example9.java1.来源B站视频代码2.一般规范先讲规范,再讲实例不要在 try 中关闭资源 Example1在finally 中或者使用 Java8的语法糖原创 2020-06-30 21:01:16 · 171 阅读 · 0 评论 -
集合排序
文章目录1. compare VS compareTo2. 数组/集合排序1. compare VS compareTo参考文献: Comparable方法中的compareTo方法的返回值的正负 判断升序 还是 降序 //Comparator 的 comparepublic interface Comparator<T> { //o1 - o2 正序 int compare(T o1, T o2); //return o1-o2 正序} //原创 2020-05-28 22:26:11 · 118 阅读 · 0 评论