ublic class Test { public static void main(String[] args) { double sum = 860.10 + 1808.09; double sum1 = 1808.09 + 860.10; // output is 2668.19 System.out.println(sum); // output is 2668.19 System.out.println(sum1); List<Double> lst = new ArrayList<Double>(); lst.add(860.10); lst.add(1808.09); Double res = lst.stream().mapToDouble(d -> d).sum(); // output is 2668.1900000000005 System.out.println(res); lst.clear(); // adding in reverse order lst.add(1808.09); lst.add(860.10); res = lst.stream().mapToDouble(d -> d).sum(); // output is 2668.19 System.out.println(res); } }
标签:Stream,1808.09,sum,list,System,累加,lst,res,out From: https://www.cnblogs.com/banxianer/p/17639737.html