private Keyword

Using the private keyword declares private visibility for a class, variable, or method. Items with private visibility are accessible only from within the class in which the item is defined. Other classes within the program cannot access the item.

Here’s an example that declares a private class variable:

private int Diameter;

Get Java For Dummies Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.