java - Comparing two set of strings -
here problem. i'm trying compare 2 different string using &&
, .equals
seems cannot give me result should be.
here code (starting think problem is) :
for(int = 0; < datalist.size(); i+=3) { string temp1 = datalist.get(i); string temp2 = datalist.get(i+1); system.out.println(temp1); system.out.println(temp2); if (temp1.equals(dataquery1)) { system.out.println("true"); if (temp2.equals(dataquery2)) { system.out.println("true"); array2.add((datalist.get(i))); array2.add((datalist.get(i+1))); array2.add((datalist.get(i+2))); } } } system.out.println("\n\narray2 size : " + array2.size()); (int j = 0; j < array2.size(); j++) { system.out.println("array2 : " + array2.get(j)); }
this array :
[0] lipase b [1] x-33 [2] ppicz?a [3] candida antarctica lipase b (calb) [4] smd1168h [5] pgap?b [6] lip 2 [7] x-33 [8] ppicz?a
and result :
lipase b x-33 candida antarctica lipase b (calb) smd1168h lip 2 x-33 array2 size : 0
the result should :
true true array2 size : 3 array2 : lipase b array2 : x-33 array2 : ppicz?a
i tried using if (temp1.equals(dataquery1) && temp2.equals(dataquery2))
doesn't work. if change dataquery1
, dataquery2
value lipase b
, x-33
respectively, code works fine.
can help?
by looks of things, you're setting dataquery1 "lipase" when should setting "lipase b". if fix that, correct output:
lipase b x-33 true true candida antarctica lipase b (calb) smd1168h lip 2 x-33 array2 size : 3 array2 : lipase b array2 : x-33 array2 : ppicz?a
Comments
Post a Comment