I\'m confused because all I keep hearing is that private variables in Java are supposed to protect the code or the variable. But if anybody has access to the code, then it m
why are variables private in java
To achieve encapsulation and this can't be accessible outside the class. This doesn't mean programmer can't change the source code.