In the following code, field1 does not have a modifier: public/protected/private
public class class1 {
String field1;
}
So what is the modifier of field1?
In the Modifier definition in Java, these are all the Modifiers that are relevant to a field:
Modifier.PUBLIC | Modifier.PROTECTED | Modifier.PRIVATE |
Modifier.STATIC | Modifier.FINAL | Modifier.TRANSIENT |
Modifier.VOLATILE;
Which of the modifier(s) does field1 have? I feel it does not have any of Modifier.PUBLIC,Modifier.PROTECTED, and Modifier.PRIVATE
I ask this because I want to access this field one via Java reflection.
Thanks. For the answers.
It indeed has no modifier.
I have tested getModifiers() for field1. It returns 0.
Thanks.
It has no modifier. For further details what this lack of modifier means see here:
http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html