If we mark our method or variable as private, then we cannot access either of them outside the class. They cannot be accessed outside the package, or outside the same class. If we want to access this in our ArraysDemo example, we cannot do that. Even if we try to, it throws an error, as shown in the following screenshot:
This is so because, if we mark any method or variable as private, we cannot access it outside that particular class. Until and unless we change it to something else, it throws an error. This applies to the variable as well.
If you want a ...