java - How do getters and setters work? -




i'm php world. explain getters , setters , give examples?

tutorial not required this. read on encapsulation

private string myfield; //"private" means access restricted  public string getmyfield() {      //include validation, logic, logging or whatever here     return this.myfield; } public void setmyfield(string value) {      //include more logic      this.myfield = value; } 




wiki

Comments

Popular posts from this blog

elasticsearch - what is the equivalent data type for geo_point in hibernate search? -

firebase - How to wait value in Ionic 2 -

Jenkins: find build number for git commit -