Why declare variables private in a class? [closed]
Folks I'll start by apologising as I'm sure this has been answered elsewhere - I just can't find an answer that explains it in a way I understand! I'm doing an MSc conversion course and there are some elementary basics that I'm still struggling with this, including this one - why making a variable private is better. Say I have a Java class called Person, with a print method. I could create it and define it as such: public class Person { public String name; public String telephoneNumber; public void print() { System.out.println(name + " " + telephoneNumber); } } Then, in a main class, I could