java面试
九童
这个作者很懒,什么都没留下…
展开
-
项目中常见的代码缺陷
1.Minor行尾注释2.Critical圈复杂度过高,if else 嵌套过深。原创 2021-07-22 09:25:58 · 505 阅读 · 0 评论 -
怎么遍历Map?
class Solution { public int firstUniqChar(String s) { Map<Character,Integer> map = new HashMap<>();//字母,索引 for(int i=0;i<s.length();i++){ if(!map.containsKey(s.charAt(i))){ map.put(s.charAt(i).原创 2021-07-11 18:36:24 · 113 阅读 · 0 评论 -
leetcode中的位运算小技巧
原创 2021-07-10 20:43:46 · 73 阅读 · 0 评论 -
LinkedList的哪些我不太记得的函数总结
java.util.LinkedList<E> public boolean offerLast(E e)Inserts the specified element at the end of this list.在此列表末尾插入指定的元素。LinkedList<Integer> list = new LinkedList<>(); list.offerLast(19);原创 2021-07-10 15:22:52 · 51 阅读 · 0 评论 -
try-catch-finally 中有return,finally中的代码是否还会执行呢?答案是——会的!
private static int test(int i){ try { i++; return 9; // throw new Exception(); } catch (Exception e) { System.out.println(i); return i; } finally { ...原创 2021-07-09 16:49:31 · 139 阅读 · 0 评论 -
数组处理合集
数组处理合集1.Arrays.sort函数使用lambda表达式实现二维数组排序int[][] pair = new int[][]{{13,4},{2,3},{5,9}}; Arrays.sort(pair, (w, q) -> (q[1] - w[1])); System.out.println(JSONObject.toJSONString(pair));运行结果如下:2.很奇怪,为什么一维数组这么写就会报错呢?3.list转换成数组class原创 2021-06-29 22:00:45 · 58 阅读 · 0 评论