Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Java Encapsulation

public class Person {
  private String name; // private = restricted access

  // Getter
  public String getName() {
    return name;
  }

  // Setter
  public void setName(String newName) {
    this.name = newName;
  }
}
 
PREVIOUS NEXT
Tagged: #Java #Encapsulation
ADD COMMENT
Topic
Name
8+9 =