最简单的解决方案是使用诸如
Math.min和
Math.max
double largest = a.nextDouble();double smallest = largest;while (a.hasNextDouble()) { double input = a.nextDouble(); largest = Math.max(largest, input); smallest = Math.min(smallest, input);}
最简单的解决方案是使用诸如
Math.min和
Math.max
double largest = a.nextDouble();double smallest = largest;while (a.hasNextDouble()) { double input = a.nextDouble(); largest = Math.max(largest, input); smallest = Math.min(smallest, input);}