encapsulation in oop

www‮ruttual.‬i.com
encapsulation in oop

In object-oriented programming (OOP), encapsulation refers to the bundling of data with the methods that operate on that data, or the restricting of direct access to some of an object's components.

Encapsulation is to make sure that "sensitive" data is hidden from users , preventing direct access to them by clients in a way that could expose hidden implementation details or violate state invariance maintained by the methods.

public class Another {

        private int a;
        private int b;
        private int c;
    
        public Another(int a, int b, int c) {
            this.a = a;
            this.b = b;
            this.c = c;
        }
    
        public Another(){
            // default
        }
    
        public int getA() {
            return a;
        }
    
        public int getB() {
            return b;
        }
    
        public int getC() {
            return c;
        }
    
        public void setA(int a) {
            this.a = a;
        }
    
        public void setB(int b) {
            this.b = b;
        }
    
        public void setC(int c) {
            this.c = c;
        }
    }
Created Time:2017-09-05 08:55:44  Author:lautturi