java从对象获取空属性
我在该对象中有一个对象,我有将近30个属性,我想从该对象中获取所有空属性
现在,我分别为每个属性设置if条件,所以我的代码非常大,java中是否有任何方法可以从对象获取null属性
请帮忙拿这个
编辑在上载数据时,我想向用户显示空字段作为错误消息
你可以在下面搜索框中键入要查询的问题!
我在该对象中有一个对象,我有将近30个属性,我想从该对象中获取所有空属性
现在,我分别为每个属性设置if条件,所以我的代码非常大,java中是否有任何方法可以从对象获取null属性
请帮忙拿这个
编辑在上载数据时,我想向用户显示空字段作为错误消息
# 1 楼答案
首先,你需要Fields。然后你get the values,然后当值为^{时添加field name。像这样的
# 2 楼答案
以下是使用反射获取所有空字段的方法: