Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

encapsulation in oop

The meaning of Encapsulation, is to make sure that "sensitive" data is hidden from users.
it is like the pojo classes in andorid studio


To achieve this, you must :::
    1. declare class variables/attributes as private
    2. provide public get and set methods to access and update the value of a private variable


example :::
    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;
        }
    }
Comment

PREVIOUS NEXT
Code Example
Java :: java run cmd 
Java :: android studio edittext enter pressed 
Java :: java get number of months between two dates 
Java :: java long to hours minutes and seconds 
Java :: write files with FileOutPutStream java 
Java :: android studio change button color programmatically 
Java :: make edittext not editable android 
Java :: is palindrome java 
Java :: getcolor deprecated android 
Java :: upper en java 
Java :: java.lang.ArrayIndexOutOfBoundsException 
Java :: java is list ordered 
Java :: java standard exceptions 
Java :: method reference in java 
Java :: BufferredReader Class 
Java :: java toggle button get state 
Java :: java vector push_back 
Java :: array contain java 
Java :: set view size android 
Java :: what is inflater in android 
Java :: rock paper scissor in java 
Java :: lambda expressions in java 
Java :: export JAVA_HOME=` mac 
Java :: java search arraylist 
Java :: GenerationTarget encountered exception accepting command : Error executing DDL 
Java :: centos 8 install java 16 
Java :: hibernate in spring boot 
Java :: java string character at index 
Java :: valueof in java 
Java :: rock paper scissors java 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =