Question: Every time an user click on the button it has to show "John - Sue" or "Sue - John".

I tried with this code:

```
public class MyActivity extends Activity {
    ArrayList<String> names = new ArrayList<String>();
    int p1, p2;

    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.myactivity);

        names.add("John");
        names.add("Sue");

        Button b = (Button) findViewById(R.id.mybutton);
        b.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {

                p1 = (int)Math.random();
                if (p1 == 0)
                    p2 = 1;
                else
                    p2 = 0; 

                String msg = names.get(p1) + " - " + names.get(p2);

                AlertDialog msgbox  = new AlertDialog.Builder(About.this).setTitle("Click here").setMessage(msg).create();
                //msgbox.setPositiveButton("OK", null);
                msgbox.setCancelable(true);
                msgbox.show();

                TextView textView = (TextView) msgbox.findViewById(android.R.id.message);
                textView.setTextSize(16);
            }
        });
    }
}

```

But i get always the same order, even i close and run again the app. How to do that?

Answer: 
If you want shuffle list:

```
Collections.shuffle(names)

```

If you want random int between 0 or 1 ([nextInt(int) javadoc](http://docs.oracle.com/javase/7/docs/api/java/util/Random.html#nextInt(int))):

```
Random random = new Random();
int randomInt = random.nextInt(2);

```
Math.random() returns a number between 0 and 1. So when you cast it to int it will always be 0.

Try this:

```
 p1 = (int)(Math.random()*2);

```