Removing Objects from an ArrayList
<p>Hi I am a bit new to Java and Android. I am working on a project which it cycles through random Activities and I am stuck with a problem for days.</p>

<pre><code>public class ActivityHelper extends Activity {
    ArrayList&lt;String&gt; classes = new ArrayList&lt;String&gt;();
    public   void addClass (){
        classes.add("Activity1");
        classes.add("Activity2");
        classes.add("Activity3");
                //etc

    }
    public  String openClass (){
        addClass();
        Random rand = new Random ();
        int crazy = rand.nextInt(classes.size());
        String cheese = classes.get(crazy);
        classes.remove(cheese);
        return cheese;  
    }   
}

// A Method in Activity1 extends ActivityHelper
public void doJob() {

    String cheese = openClass();
    try {               
        @SuppressWarnings("rawtypes")
        Class ourClass = Class.forName("com.activity.dan." + cheese);
        Intent ourIntent = new Intent(Activity1.this, ourClass);
        startActivity(ourIntent);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}
</code></pre>

<p>The program perfectly cycles through the classes but my problem is the <code>classes.remove(cheese);</code> doesnt work. I am hoping once the Class is opened it will be removed from the ArrayList and wont be used again if the <code>doJob();</code> method is called on another class. I tried using static and putting the remove list in the <code>Activity1</code> but nothing seems to work. Your help will be appreciated. </p>
