随笔分类 -  基础

摘要:public class T1 { public static void main(String[] args) { ZonedDateTime now = ZonedDateTime.now(); System.out.println(now); } } 阅读全文
posted @ 2023-11-22 10:49 爱新觉罗LQ 阅读(10) 评论(0) 推荐(0) 编辑
摘要:+ 的优先级 高于 << + 的优先级 高于 << 阅读全文
posted @ 2023-11-06 12:36 爱新觉罗LQ 阅读(5) 评论(0) 推荐(0) 编辑
摘要:按列取出二维数组 int[] arr2 = new int[row]; for (int i = 0; i < col; i++) { // 列数 for (int j = 0; j < row; j++) { arr2[j] = arr[j][i]; } } 阅读全文
posted @ 2023-11-02 13:12 爱新觉罗LQ 阅读(6) 评论(0) 推荐(0) 编辑
摘要:判断周围8个方向的位置 static int[][] offsets = {{0, 1}, {1, 1}, {1, 0}, {1, -1}, {0, -1}, {-1, -1}, {-1, 0}, {-1, 1}}; for (int i = 0; i < row; i++) { for (int 阅读全文
posted @ 2023-10-26 23:04 爱新觉罗LQ 阅读(11) 评论(0) 推荐(0) 编辑
摘要:从二维数组中截取连续行 int[][] temp = Arrays.copyOfRange(arr, 1, 2); // 截取第二行 阅读全文
posted @ 2023-10-25 23:55 爱新觉罗LQ 阅读(10) 评论(0) 推荐(0) 编辑
摘要:已知BST的前序遍历,还原BST arr数组:前序遍历 list:排序后的 arr 数组【BST的 中序遍历】 public static TreeNode getRoot(int[] arr, List<Integer> list){ int index = -1; for (int i = 0; 阅读全文
posted @ 2023-10-23 11:00 爱新觉罗LQ 阅读(10) 评论(0) 推荐(0) 编辑
摘要:给定二叉树的前序遍历,遍历是否是 BST public static boolean isValid(int[] arr, int start, int end, int min, int max){ if (start > end){ // start > end:当前子树为空,返回 true,因 阅读全文
posted @ 2023-10-23 10:58 爱新觉罗LQ 阅读(8) 评论(0) 推荐(0) 编辑
摘要:判断一个数是质数 public class PrimeNumberChecker { public static boolean isPrime(int number) { if (number <= 1) { return false; // 1和负数不是质数 } if (number <= 3) 阅读全文
posted @ 2023-10-20 16:48 爱新觉罗LQ 阅读(8) 评论(0) 推荐(0) 编辑
摘要:利用 Stream 流将 TreeSet 转成数组 Integer[] arr = set.stream().toArray(Integer[]::new); 阅读全文
posted @ 2023-10-20 11:23 爱新觉罗LQ 阅读(54) 评论(0) 推荐(0) 编辑
摘要:整型数组逆序 由于 int型数组没有实现 comparator 接口,所以不支持逆序排序,所以我们建数组的时候就建成 Integer型就好了 Scanner in = new Scanner(System.in); int target = Integer.parseInt(in.nextLine( 阅读全文
posted @ 2023-10-18 11:49 爱新觉罗LQ 阅读(7) 评论(0) 推荐(0) 编辑
摘要:List list 删除指定元素 List<Integer> list1 = new ArrayList<>(); list1.add(1); list1.add(2); list1.add(4); list1.add(3); list1.remove((Integer)4); System.out 阅读全文
posted @ 2023-10-17 23:34 爱新觉罗LQ 阅读(69) 评论(0) 推荐(0) 编辑
摘要:测试类中的 init() 方法【前有 @Before 注解】 package com.llq.mapper; public class MonsterMapperTest { // 属性 private SqlSession sqlSession; private MonsterMapper mon 阅读全文
posted @ 2023-10-16 13:20 爱新觉罗LQ 阅读(31) 评论(0) 推荐(0) 编辑
摘要:清空StringBuilder sb.setLength(0); 阅读全文
posted @ 2023-10-16 13:19 爱新觉罗LQ 阅读(1) 评论(0) 推荐(0) 编辑
摘要:复制一个字符串多次 String repeat = temp.toString().repeat(count); 394. 字符串解码 核心思路: 加入最后一个 ],在弹出时候 先收集括号内所有的字母 弹出 [ 收集数字 class Solution { public String decodeSt 阅读全文
posted @ 2023-10-14 00:09 爱新觉罗LQ 阅读(20) 评论(0) 推荐(0) 编辑
摘要:Arrays.binarySearch 详解 前提:非降序排序数组 binarySearch(Object[] a, Object key) a:待搜索的数组 key:要搜索的值 逻辑条件 可以找到:返回一个 >=0 的索引 找不到:【从 1 开始计数】 在数组范围内,返回 -(key 将要插入的位 阅读全文
posted @ 2023-09-22 11:41 爱新觉罗LQ 阅读(898) 评论(0) 推荐(0) 编辑
摘要:接口编程 在创建好 Bean 实例后,判断是否要初始化,心得: 容器中常用的方法是:根据该类是否实现了某个接口,来判断是否要执行某个业务逻辑 这其实就是 java基础的 接口编程的 实际运用 package com.llq.spring.ioc; /** * Spring 原生 Ioc 容器 */ 阅读全文
posted @ 2023-09-18 11:04 爱新觉罗LQ 阅读(13) 评论(0) 推荐(0) 编辑
摘要:最大相连男生 import java.util.Scanner; import java.util.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { static int row; static int col; static 阅读全文
posted @ 2023-09-15 15:05 爱新觉罗LQ 阅读(8) 评论(0) 推荐(0) 编辑
摘要:数组截断 String[] split = sb.toString().trim().split(" "); String[] res = Arrays.copyOfRange(split, 1, split.length); // 将第一个截断!!! 阅读全文
posted @ 2023-09-14 12:54 爱新觉罗LQ 阅读(8) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示