Tell me please, the problem is this: There is a dynamic array

ArrayList<String[]> myPoints; 

In String [] coordinates, such as 59.9823482. How to run through the loop through the array, and if there is a match, then change the element to + 0.0000001, but so that again does not coincide with the others ..

    1 answer 1

     for(int i = 0; i < myPoints.size(); i++) while(checkValue(myPoints.get(i)) myPoints.get(i) = Double.parseDouble(myPoints.get(i))+0.0000001; 

    chekValue () :

     private boolean chekValue(String value) for(int i = 0; i < myPoints.size(); i++) if(myPoints.get(i).equals(value)) return true; 

    PS If you want, you can replace it with streams / foreach

    • okay element 4 is equal to "10". element 7 is equal to "10". element 15 is "10.000001". what then? - Wlad
    • 1) make a copy of this array. 2) the loop inside the loop, where you will enumerate the elements of these arrays. 3) inside this, make an if condition where you will compare the elements from the original array with the elements from the copy. 4) if it finds a match, change the value (but only in one array). ps it all depends on the task itself. if you need to increase the value for each repetition - continue like this. if "there is at least 1 element - zoom in" - then you can stop the cycle. and so on and so on - Wlad
    • I did not understand anything .. It is necessary that there are no identical coordinates, therefore I add 0.0000001 .. I wonder how long this code will work if 5000 lines are checked at two coordinates .. - Alex455 September