I have seen the answer a here and I am not sure it answers my issue. So I have an arraylist of Float type containing a bunch of numbers. I wish to remove all the numbers which are 30 more or less than the previous value. So, I am comparing 'n' and 'n+1' and removing 'n+1' if (n+1)>(30+n) and vice versa. I have written the following code but my solution isn't working. 
for(int i = 0; i<hr_list.size()-1; i++)
    {
        Float x= hr_list.get(i);
        Float y = hr_list.get(i+1);
        if(y>(x+30.0f)||y<(x+30.0f))
        {
            hr_list.remove(i+1);
        }
    }
 
     
     
     
     
    