From the course: Java 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Understanding encapsulation - Java Tutorial
From the course: Java 8 Essential Training
Understanding encapsulation
- Java is an object-oriented language and one of the most important principles of object-oriented programming is encapsulation. Encapsulation means that you're packaging complex functionality to make it easy to use. When you first Java applications, most new programmers will put all of their code into the main method, and I've been doing that so far in this course. But you quickly find out as your applications get larger and more complex, that putting all of the code into one place makes it very difficult to manage. So instead you want to break the code out into individual classes, grouping the functionality as the logic dictates for your application. This gives you some great advantages. For example, not all functionality should be available to all parts of an application. And encapsulation lets you restrict access as needed. Each class can be placed in a particular package, and within the class, methods can be marked as public, private, or protected, so only those parts of the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
-
Understanding encapsulation7m 19s
-
Creating and instantiating custom classes4m 51s
-
Creating nested and anonymous classes4m 17s
-
Visualizing class relationships3m 43s
-
Storing data in instance variables6m 2s
-
Declaring instance and static methods3m 59s
-
Using constructor methods4m 56s
-
Using static variables as constants3m 3s
-
Declaring and using enum types5m 17s
-
-
-
-
-