In android coding i have two different arraylist. i have matched both arraylist elements. But my problem is that when my matched data found in loop, if statement not running. this is my code
for (int i = 0; i < mname.size(); i++)
{
if(i<jsonArray.length())
{
JSONObject jo = jsonArray.getJSONObject(i);
String paid = jo.getString("name");
instname.add(paid);
}
else
{
instname.add("0");
}
System.out.println(instname.get(i)+ " " + i );
for(int j=0;j<mname.size();j++)
{
System.out.println("instname "+i + " " + "mname "+j);
if(instname.get(i) == mname.get(j))
{
System.out.println("instnam=" + instname.get(i));
System.out.println("mem="+ mname.get(j));
pay = instname.get(i);
break;
}
}
}
Here in code mname
and instname
is arraylist. mname has 2 names, 'name1' and 'name2' and instname hase 1 name, 'name2'. In my logcat result like
name2 0
instname 0 mname 0
instname 0 mname 1
0 1
instname 1 mname 0
instname 1 mname 1
instname 0
and mname 1
is true matched data contains both name2
, but my if condition not run. it results pay = null