Access Modifiers
- What are they?
- Public
- Default
- Pro..[1/2]
- Pro..[2/2]
- Private
What are Access Modifiers?
Access Modifiers control how variables and methods are accessed within a class, by other classes in the same package, or by classes in different packages, ensuring proper data handling, validation, and security.
The four modifiers are `public`, `default`, `protected`, and `private`.
private static int employeeCount = 1020;
protected Data companyData;
private ArrayList<Employee> list;
public static void addEmployee(Employee wkr) {
list.add(wkr);
employeeCount++;
}
class Employee {...} //default modifier - no attribute