0

static along with private

If I understand this right, it means static variable have common values for all the objects created in a specific class (correct me if I'm wrong). But why does an error occur when I try to initialize an attribute with static and private property? i.e. public class Person { private String name; private static String nationality; } Help!

6th Sep 2016, 6:02 PM
sixty9er
sixty9er - avatar
1 Réponse
+ 1
private values access only in class but static values can be access from other classes (ex. ClassName.staticValue).so static values and functions have to be public
6th Sep 2016, 6:15 PM
bayram akdemir
bayram akdemir - avatar