I'm just wondering if there's any difference between using the set and get method, and just using object.variableName to set and get? Thanks.
package hello;
public class Helloworld {
int num;
public static void main(String[] args) {
Helloworld hello1 = new Helloworld();
Helloworld hello2 = new Helloworld();
hello1.num = 5;
System.out.println(hello1.num);
hello2.setNum(5);
System.out.println(hello2.getNum());
}
void setNum(int i) {
this.num = i;
}
int getNum() {
return this.num;
}
}