简体   繁体   中英

how do I find out if a Java field has the transient modifier?

In the Java reflection world -

how do we find out if a Field object has the transient modifier?

http://docs.oracle.com/javase/tutorial/reflect/member/fieldModifiers.html

the documentation is not helping.

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

Field field = YourClass.class.getField("fieldName");
boolean isTransient = Modifier.isTransient(field.getModifiers());

For more details see Class Modifier

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM