How to instantiate fragment class using class name instead of index : <p>I have two fragment class named <code>SessionTab</code> and <code>BillingTab</code>and i am trying to create instance of those class using</p>

<pre><code>SessionTab sessionTab = (SessionTab) getSupportFragmentManager().getFragments().get(1);
</code></pre>

<p>but sometimes index for those classes are reversed and then it causes <code>ClassCastException</code> </p>

<p>How can i get instance of those fragment class by passing class name instead of index or any way to make sure that index of those class stays the same everytime so it doesn't cause <code>ClassCastException</code></p>
