I added a string into an arraylist, but when i want to retrieve it, it does not go into if conditional in the code below:

ArrayList a=new ArrayList();
        a.add("12");
        System.out.println(Integer.toString(1)+","+Integer.toString(2));
        if((Integer.toString(1)+Integer.toString(2))==a.get(0)){
            System.out.println("this is working here");
        }

What is the problem here?

you are using the == operator to compare Strings' values, you should use the equals method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.