title: Need help about generic types and Objects
body: <p>I have created generic SingleLinkedList to store my own created objects from the class I wrote.
  The problem is I don't know how to display that objects in a generic SingleLinkedList.</p>
  <p>I tried T.getClass(). etc but I failed.</p>
  <p>Thanks.</p>
  <p>Edit:</p>
  <pre><code>if(head.getData() instanceof Company) 
      {
          if(head!=null) 
          {
              Node&lt;T&gt; temp=head;
              while(temp!=null) 
              {
                  Company comp=(Company) temp.getData();
                  System.out.println(comp.getName());
                  temp=temp.getNext();
              }
          }
      }
  </code></pre>
  <p>This is the current statements that is working for my case
  I'm curious about is there a another approaches for this kind of intention.</p>
  <p>Thanks for the answer below,I used &quot;instanceof&quot;</p>