Java tutorial for beginners || Encapsulation in Java || Falcon Geeks

Опубликовано: 10 Январь 2023
на канале: Falcon Geeks
49
4

What is Encapsulation in Java
Encapsulation means wrapping variables with the methods that manipulate the variables. In simple terms limiting direct access to variables by declaring as private, that means it can only be accessed within the same class. No outside class can access private variable of other class.

To access the private variable, we set up public getters and setter's methods. Using these methods, we can update and read the private variables and then the outside class can access those private variables. This way variables can only be accessed by public methods thus making the private variables and their implementation hidden for outside classes. That’s why encapsulation is known as data hiding.


To achieve Encapsulation, you must:

declare class variables/attributes as private
provide public get and set methods to access and update the value of a private variable


На этой странице сайта вы можете посмотреть видео онлайн Java tutorial for beginners || Encapsulation in Java || Falcon Geeks длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Falcon Geeks 10 Январь 2023, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 49 раз и оно понравилось 4 зрителям. Приятного просмотра!