title: access non static data in static method in java
body: <p>i am a new java learner and i am making a program where i want to access the value of a not static data member in a static method 
  but rule says that i cant not do this but we can access it after creating a object 
  my question is that if i make a object of that class that old value of that data member is erase why  ?
  how can i use it old value of a not static data member in a static method </p>
  
  <pre><code>import java.util.Scanner;
  class emp
  {
       String name;
       int rate;
       static String c_name="TCS";
  
  
       void setdata(String n,int s)
  
       {
         name=n;
         rate=s;  
  
       }
       static void employee_salary_cal(int t)
        {
          int day,rate1,Total;
          day=t;
          emp e2=new emp();
          rate1=e2.rate;
          Total=rate1*day;
  
          System.out.println("Total salary " +Total);
        }  
  
       void showData()
       {
         System.out.println("Employee name = " +name);
         System.out.println("Employee pay rate per day = " +rate);
       }
  
  
  }
  
  class emp_main
  {
    public static void main(String args[])
       { 
          int da;
          emp e1=new emp();
          e1.setdata("alex",100);
          System.out.println("Company name = " +emp.c_name);
          e1.showData();
          System.out.println("Enter Work days in months ");
          Scanner sc=new Scanner(System.in);
          da=sc.nextInt();
          emp.employee_salary_cal(da);
  
  
  
       }
  }
  </code></pre>
  
  <p>program output :  </p>
  
  <pre><code>Company name = TCS
  Employee name = alex
  Employee pay rate per day = 100
  Enter Work days in months
  25
  Total salary 0
  </code></pre>