Supplement before entering the accessor method
What is [encapsulation]?
・ One of the features of object-oriented languages -Store relevant data and programs in a container ・ Container = object (* The name of the container was described as an object. We will correct it.)
・ Accommodates fields and methods ・ The contained items cannot interfere from outside the class. (* It seems that there are some that can interfere. Thank you for pointing out.)
-Fields and methods contained in the object are protected from external interference. ・ Encapsulation is to put it in an object and prevent it from being touched by others.
What is [Accessor / Accessor Method]?
-Methods provided for the purpose of mediating field access -Update and retrieval of field values go through the method of the object (container). -All field values cannot be accessed without the methods "set ○○" and "get ○○". ・ This "set ○○" and "get ○○" are called accessors.
What is [Field]? ・ One of the components of class
About [Class] · Consists of fields and methods (Example)
public class test{
int a; //field
String b; //field
public int getA{ //Method
return x;
}
public void setB(String b){ //Method
this.b = b;
}
}