title: Find the right child-class during iteration of father-class Generics/Java/OOP
body: <p>I think explaining my question via code is easier.</p>
  <p>Given a sales company which has 2 sales employee for example:</p>
  <pre><code>public class Employee()
  {
  private int salary;
  }
  public class SalesEmployee1 extends Employee()
  {
  private int commisionRate;
  
  }
  
  public class SalesEmployee2 extends Employee()
  {
  private int commisionRate;
  }
  </code></pre>
  <p>Suppose I have a vector: <code>Vector&lt;Employee&gt; v = new Vector&lt;&gt;();</code>
  I need to iterate over that vector and find the SalesEmployee1 with the lowest commission(each salesEmployee computes it differently so its a different commission) .
  How can I ask whether I am a SalesEmployee1 without using instanceof?
  I thought about adding a function in the father class which every child overrides</p>
  <pre><code>public boolean myClass(String name)
  {
      return name.equals(ClassName for example SalesEmployee1);
  }
  </code></pre>
  <p>and than do something like that:</p>
  <pre><code>for(Employee e : v)
  {
      if(e.myClass(&quot;SalesEmployee1&quot;)
           doSmth()...
  }
  </code></pre>
  <p>Is this method right? can anyone suggest another solution because I feel like im doing somthing wrong because this feels like a instance of variation.
  Thanks!</p>