the targetPixValList is a list contains Double objects and it contains also similar values in successive position in the list, and when i tried to compare two Double values using Code_1, the cnt returns zero. and when i used code_2, the cnt returns value.
and the type of the list is
why "==" operator does not work with Double?
Code_1:
int cnt = 0;
    for (int i = 0; i < cs.targetPixValList.size()-1; i++) {
        if (cs.targetPixValList.get(i) == cs.targetPixValList.get(i+1))
            ++cnt;
    }
Code_2:
 int cnt = 0;
    for (int i = 0; i < cs.targetPixValList.size()-1; i++) {
        if (cs.targetPixValList.get(i).equals(cs.targetPixValList.get(i+1)))
            ++cnt;
    }
 
     
     
     
    