title: Reference of a non static variable
body: <p>I have class <strong>Employe</strong> that has variables like id , name ... and 2 other classes that <em>inherit</em> from Employe : <strong>Seller</strong> and <strong>Cashier</strong>. 
  To calculate their salaries, I created a method in each one of <strong>Seller</strong> and <strong>Cashier</strong> but I need to access the name via the name getter method in <strong>Employe</strong> so I'd have :</p>
  
  <pre><code>System.out.println("The salary is "+Seller.getName() +" is : " +salary);
  </code></pre>
  
  <p>Once I type that, I get an error sayingI need to make the name variable to static, but I need it as non static since I'm creating multiple objects using the name variable. 
  Any solution to this problem?</p>
  
  <p>EDIT : 
  This is the Employe class : </p>
  
  <pre><code>public class Employe {
  protected int id;
  protected  String name;
  protected String adresse;
  protected int nbrHours;
  
  public Employe () {
  }
  
  public Employe (int id, String name, String adresse, int nbHours)
  {
      this.id=id;
      this.name=name;
      this.adresse=adresse;
      this.nbrHours=nbHours;
  }
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public  String getName() {
      return name;
  }
  
  public void setNom(String name) {
      this.name = name;
  }
  
  public String getAdresse() {
      return adresse;
  }
  
  public void setAdresse(String adresse) {
      this.adresse = adresse;
  } 
  </code></pre>
  
  <p>}</p>
  
  <p>This is the Seller class : </p>
  
  <pre><code>public class Seller extends Employe {
  private int prime;
  public Seller (int id, String name, String adresse, int nbHours,int prime)
  {
      super(id,name,adresse,nbHours);
      this.prime=prime;
  }
  
  public int getPrime() {
      return prime;
  }
  
  public void setPrime(int prime) {
      this.prime = prime;
  }
  
  @Override
  public String toString() {
  
      return super.toString() +" [prime=" + prime + "]";
  }
  
  public void salaireSeller ()
  {
      int salaire = 0;
      if(nbrHours&lt;160)
      {
      salaire = nbrHours * 10 + prime;
      System.out.println("La salaire de "+Responsable.getName() +" est : " +salaire);
      }
      else if(nbrHours &gt;160)
      {
          int Extra= (160 - nbrHours) * 12;
          int salaire1 = 160 * 10000 + prime;
          salaire= Extra + salaire1;
          System.out.println("La salaire de "+Seller.getName() +" est : " +salaire);
      }
  
  }
  </code></pre>
  
  <p>In the Main class I created a Seller object : </p>
  
  <pre><code>Seller Sel1 = new Seller(2, "Alex", "Miami", 18, 200);
  </code></pre>
  
  <p>now I want to calculat its salary using the SalaireSeller() method in the Main class of course :</p>
  
  <pre><code>Sel1.salaireSeller();
  </code></pre>
  
  <p>but in the Seller class : </p>
  
  <pre><code>System.out.println("La salaire de "+Responsable.getName() +" est : " +salaire);
  </code></pre>
  
  <p>it says I need to set Name to static, this will give every object the same name</p>