This is basic question but still i don\'t understand encapsulation concept . I did\'t understand how can we change the properties of class from other class.because whenever
It seems you are running two different classes separately and assuming the changes done to attributes when you run EmployeeTest will reflect in Employee run. Note that changes will reflect in the same JRE instance. Excuse me in case i have misunderstood your problem.
EDIT: As per the user input. Here is the code how you can access and update the static member values:
class Employee {
public static int empid;
public static String empname;
public static void main(String[] args) {
System.out.println("print employe details:" + empid + " " + empname);
}
}
// EmployeeTest class
public class EmployeeTest {
public static void main(String[] args) {
Employee e = new Employee();
e.empid = 20;
e.empname = "jerry";
Employee.empid = 10;
Employee.empname = "tom";
Employee.main(null);
}
}