Consider the following class
public final class Constant {
public static final String USER_NAME="user1";
//more constant here
}
This class in the package B.
Now I am going to use this in package A. Consider following two ways which can use.
Method 1- use import B.Constant
import B.Constant;
public class ValidateUser {
public static void main(String[] args) {
if(Constant.USER_NAME.equals("user1")){
}
}
}
Method 2- use import static B.Constant.USER_NAME;
import static B.Constant.USER_NAME;
public class ValidateUser {
public static void main(String[] args) {
if(USER_NAME.equals("user1")){
}
}
}
My question is is there any difference or advantage normal import over static import in this case?