Skip to content
Advertisement

Java finding minimum value from for loop

I was having some problem when trying to find the minimum distance and from the minimum distance, I then plot two circles onto the map.

JavaScript

Currently I am getting 15, 3, 15, 14 as DIST but I could not get the minDist as it is not printed out. Any ideas?

Thanks in advance.

Advertisement

Answer

You probably want:

JavaScript

and initialize minDistance to Double.MAX_VALUE: double minDistance = Double.MAX_VALUE

The original few lines does not make much sense, because minDistance < distance would never evaluates to true since you just set minDistance = distance;

JavaScript

Updated:

More complete solution as the point above is not the only issue:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement