Asking about access modifiers in java!
public class Program { public static void main(String[] args) { //James Worker worker1 = new Worker(); worker1.name = "James"; worker1.salary = 200000; //Tom Worker worker2 = new Worker(); worker2.name = "Tom"; worker2.salary = 150000; System.out.println(CalculateTotalSalary(worker1.salary,worker2.salary)); } //complete the function to calculate the total salary static int CalculateTotalSalary(int a, int b){ int sum = a + b; return sum; } } class Worker{ String name; int salary; } If static method cannot access to non-static variables why the //System.out.println(worker1.salary,worker2.salary)" works? //I think worker1.salaray and and worker2.salary are non static variable. Am I wrong , sir?