Are static setter/getters allowed?
if your Properties are static
then Getters and setters
will also be static
.. its all depends on You..
Getters and setters can be static if they get/set static fields.
yes you can and that class whatever that object/variable was defined they looks like
private static String abc = "";
and you can access this object using get/set method
public static String getString(){
return abc;
}
public static void setString(String newAbc){
abc = newAbc;
}
and you can use this like this way Test.getString(); or Test.setString("new string");
you can also define this get/set method as normal means without defined the static keyword but for that you need to create the instance of that class. The static was used for without creating an instance of the class you can access their member.