You typically do not do String comparison using ==, try using the equals(..) method instead - in your case directly on your ArrayLists.
if (user.equals(mine)) { // Start a new activity. } Btw, you should consider using generics for your lists, e.g. ArrayList<String> mine = new ArrayList<String>(); On Sep 16, 4:27 pm, Zwiebel <hunzwie...@gmail.com> wrote: > I need to have two arraylists. I declared them. I declared a "mine" > arraylist and an "user" arraylist with this code: > > ArrayList mine = new ArrayList(); > ArrayList user = new ArrayList(); > > I want to store in these values, what are will be important to contact > with the user: > I added values to my mine arraylist: > mine.add("0"); > mine.add("1"); > mine.add("0"); > > I want to add a values to the user named arraylist if the user press a > button. So I added this code: > user.add("0"); > > and > > user.add("1"); > > to an another button. > > I added two > > Log.i("user", user.toString()); > > line to the buttons so I can follow how the arraylist looks like in > the appropriate moments. > > Then if the user clicks an another button, I want to compare these > lists, so I implemented the following code: > > for (int j = 0; j < user.size(); j++) { > for (int k = 0; k < mine.size(); k++) { > if (user.get(j) == mine.get(k)) { > //start a new activity > } > > If the two arraylists are the same in the order and in values, I want > to show a new screen (its name is for example good), and if not I want > to show an another( its name is for example lose). But I have a > problem. My program is only show my lose screen if the user only > clicked the button which add 1 to the arraylists, or if he/she only > clicked the button which add 0 to the arraylist. How can I make my > program to run as I want? Thanks in advance -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en