Public vs. Private in Java: Learn how access modifiers work in Java and when to use public or private attributes in Object-Oriented Programming (OOP).
In this tutorial, we'll look at practical examples to understand how to control access to attributes and classes, how to import classes from other packages, and why some attributes can be used from other classes while others remain restricted.
You'll also learn how the public and private access modifiers work, a fundamental concept before moving on to encapsulation, constructors, inheritance, and other important pillars of Java.
If you're learning Java from scratch or want to improve your Object-Oriented Programming skills, this video will help you understand one of the most important concepts in the language.
00:00 Introduction
00:44 Creating a new package
00:58 Creating a new class
01:21 Importing classes from another package
02:24 What happens if we don't use access modifiers?
03:05 Public Access Modifier
04:24 Private Access Modifier
05:28 Conclusion
#Java #OOP #ObjectOrientedProgramming #JavaTutorial #Programming #SoftwareDevelopment #JavaDeveloper #Backend #Coding #softwaredevelopment #code