get in set method code example
Example 1: java get set
class Employ
{
public String name; //name of the employ
public String getName() //Get the name
{
return name;
}
public String setName(String newName) //Set the name
{
this.name = newName;
}
}
Example 2: set get javascript
var person = {
language : "en",
get lang() { return this.language; },
set lang(lang) { this.language = lang; }
};
document.getElementById("demo").innerHTML = person.lang;
person.lang = "es";