![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
java
qq_27493017
这个作者很懒,什么都没留下…
展开
-
BeanUtils.copyProperties,忽略目标对象中不为空的字段
public static String[] getNullPropertyNames(Object source) { final BeanWrapper src = new BeanWrapperImpl(source); PropertyDescriptor[] pds = src.getPropertyDescriptors(); Set emptyNames = new HashSet(); for (PropertyDescriptor pd : pds) { .原创 2021-06-01 14:55:31 · 1528 阅读 · 0 评论 -
反射获取字段的值与非空校验
获取指定字段的值 // 通过字段对应的get方法 public Object getFieldValueByName1(String fieldName, Object obj) { try { String firstLetter = fieldName.substring(0, 1).toUpperCase(); String getter = "get" + firstLetter + fieldName.substring(1); Met原创 2021-05-18 10:52:40 · 561 阅读 · 0 评论 -
反射方式给List<Integer>中设置了String,将String 转成Integer
public static void main(String[] args) throws Exception { List<Integer> array = new ArrayList<Integer>(); Class c = array.getClass(); Method method = c.getMethod("add", Object.class); //getMethod获取方法 method.inv.原创 2020-12-16 15:21:49 · 326 阅读 · 0 评论 -
面试题:
下面程序的运行结果 求从10到1000中能被5或者7整除的数的和 使用递归计算斐波那契数列的通项,已知,,以后每项都是前两项的和 HashMap和HashTable的区别 请简单写一下对MVC架构的理解 描述一下Spring的依赖注入 谈一下SpringBoot的优缺点 一个球从100m高度自由落体,每次落地后反跳到原来的一半,在落下,求第10次落地时,共经过多少米,第10次反弹多高? 写常用的设计模式,并实现单例模式 String sql = "delete from book w原创 2020-09-29 20:25:10 · 73 阅读 · 0 评论 -
面试总结
1、union与union all的区别 Union:对两个结果集进行并集操作,不包括重复行,同时进行默认规则的排序; Union All:对两个结果集进行并集操作,包括重复行,不进行排序; 2、java中拼接字符串的方式 +:用于小数据量的操作,使用StringBuilder的append方法进行追加,但是每循环一次都会创建一个StringBuilder对象,且都会调用toString方法转换成字符串 Join:StringUtils.joinJoin和StringBuffer相差不大,Join原创 2020-09-03 16:40:29 · 68 阅读 · 0 评论 -
xml、bean之间的转换
package cn.gov.customs.conveyance.util; import com.thoughtworks.xstream.XStream; import com.thoughtworks.xstream.io.xml.DomDriver; import com.thoughtworks.xstream.security.NoTypePermission; import com.thoughtworks.xstream.security.NullPermission; import .原创 2020-08-03 18:01:54 · 352 阅读 · 0 评论 -
Random,在指定范围内产生多个不同的随机数
1.基本使用 Random rd = new Random(); int i = rd .nextInt(100);//[0,100) 2.在指定范围内产生多个不同的随机数 /** * 此方法中产生的随机数的范围[min,max] * @param min 随机数所在范围 最小 * @param max 随机数所在范围 最大 * @param n 需要产...原创 2018-08-08 16:12:05 · 3601 阅读 · 0 评论