- 剔除字符串的空格
- 没有泛型的List集合判断为空
- 集合判空
- list != null && list.size() > 0
- CollUtil.isEmpty(mdpCompensationStandarList)
- CollectionUtils.isNotEmpty()
- 字符串判空
- StringUtils.isEmpty(mdpThreePhaseInfoDTOList.get(i).getTreatmentMethod())
- !CommonUtils.isEmpty(strPageNo)
- StrUtil.isNotBlank()
- !StringUtils.nullOrBlank(resultStr)
- String str = "1";(Controller接收)
- System.out.println(StringUtils.isNotEmpty(str) ? "不空" : "空");
- int类型判空(Controller接收)
- pointsRecordParameter.setType(null != pointsQueryDto.getType() ? pointsQueryDto.getType() : 0);
- 时间类型判空(Controller接收)
- if (null != pointsQueryDto.getStartTime()) pointsRecordParameter.setStartTime(pointsQueryDto.getStartTime());
- 数组判断是否为空
- criticalPointJsonArray.isEmpty()
- 可添加多个对象到集合
- 实体转换 把第一个对象转换到第二个对象里面 后续操作第二个对象
- MsExpertOrderCopy data = new MsExpertOrderCopy();
- BeanUtil.copyProperties(params, data);
- 生成UUID 添加逻辑主键
- String id = IdUtil.simpleUUID();
- 集合赋值
- 把第一个参数集合的对应值 赋值到 第二个集合中 以后操作第二个集合
- BeanUtil.copyProperties(request, msExpertOrderCopy);7
- 取出第一个值
- 北京-BJ
- deptld.split("-")[0] 北京
- 自定义异常
- //Exception in thread "main" java.lang.RuntimeException: 权限不足!
- throw new RuntimeException("权限不足!");
- 创建一个新的 Map
- Map<String,String> map= Maps.newHashMap();
- 数组转集合
- String key[] = {"1", "2", "3", "4"};
- System.out.println("集合" + CollectionUtils.arrayToList(key));
- List提取某个字段转换成List
- List userIds = list.stream().map(Student::getName).collect(Collectors.toList());
- or
- List userIds = list.stream().map(student -> student.getName()).collect(Collectors.toList());
- 三元运算符 ----》替换
- String re = "222";
- re = re != null ? re.replaceAll("111", "") : null;
- 创建List元素
- 创建不可变List的单个元素
- List ids = Collections.singletonList("CATJ0D000206");
- 创建可变List元素
- List ids = Arrays.asList("CATJ0D000206");
- 判断是否是某个类型
- 左边是待判断的,右边是你设置的类型
- System.out.println(ids instanceof List)
- 强转为Object类型
- entries.getValue():返回的是Object类型
- 所以需要把它强制转换为Object类型输出
- Arrays.toString((Object[]) entries.getValue())
- Map Foreach循环
- map.forEach((k, v) -> System.out.println(k + ":" + v));
- 异常打印堆栈信息
- 创建空的List
- 创建空的Map
- 字符串判断是否相等。
- Objects.equals("Char",Char);
posted on
2021-07-05 10:36
(Play)
阅读(
113)
评论()
编辑
收藏
举报
点击右上角即可分享
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~