How to use BigInteger in Java - 2
May 31, 2023
1 min
One of the methods used in Java is encapsulation. This prevents direct data modification in the class and allows changes only by methods.
public class Test {private String site; // Setting restrictions on external access.public String getSite() { // get methodreturn site;}public void setSite(String newSite) { // set methodthis.site = newSite;}}public static void main(String[] args) {Test myObj = new Test();myObj.site = "google.com"; // error.myObj.setSite("google.com");// System.out.println(myObj.site);}