এনক্যাপসুলেশন (Encapsulation) Object-Oriented Programming

- Encapsulation হলো Object-Oriented Programming এর একটা গুরুত্বপূর্ণ concept। এটার মাধ্যমে class-এর data গুলোকে বাইরের access থেকে লুকানো হয়।
যেমন – variable গুলোকে private রাখা হয়। তারপর সেই data access করার জন্য ব্যবহার করা হয় Getter আর Setter method। এর ফলে data হয় secure, code হয় easy to maintain, আর system পায় flexibility।

  public class Employee {
   private String name;
   public String getName() {
    return name;
  }
   public void setName(String name) {
    this.name = name;
  }
 }
  public class EmployeeMain {
   public static void main(String[] args) {
    Employee employee = new Employee();
    employee.setName("Abdullah");
    System.out.println("Name: "+ employee.getName());
  }
 }

output: Abdullah

Comments

Popular posts from this blog

Java Introduction in Bengali (জাভা পরিচিতি) JVM, JRE & JDK Explained

JDK Download & Install Process in Bangla - জাভা শিখুন বাংলায়!