0
我想根據字段類型執行一些邏輯。java如何檢查我從getType函數獲得的類型
我得到了場(Field類)類型:
Field[] fields = o.getClass().getFields();
for (Field field : fields) {
// which and how to use:
//Class<?> t = field.getType();
// Type type = field.getType();
if (type == byte) {
} else if (type == int) {
}
}
我怎麼能知道我得到哪些類型?
你知道你得到哪些類型? - nvm – Joseph118 2014-11-21 06:34:41
否(原始(bye,short,int,double ...)或其他類) – user3668129 2014-11-21 06:40:05