fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class CpuUsage {
  8. private float usage;
  9. public CpuUsage(float f) {
  10. this.usage = f;
  11. }
  12. public float getUsage() {
  13. return this.usage;
  14. }
  15.  
  16. }
  17.  
  18. /* Name of the class has to be "Main" only if the class is public. */
  19. class Ideone
  20. {
  21. public static void main (String[] args) throws java.lang.Exception
  22. {
  23. List<CpuUsage> list = new ArrayList();
  24. list.add(new CpuUsage(2.0f));
  25. list.add(new CpuUsage(10.0f));
  26. list.add(new CpuUsage(22.0f));
  27. list.add(new CpuUsage(2.4f));
  28. list.add(new CpuUsage(5.0f));
  29. CpuUsage u = list.stream().min(Comparator.comparing(CpuUsage::getUsage)).get();
  30. System.out.println(u.getUsage());
  31. }
  32. }
Success #stdin #stdout 0.19s 2841600KB
stdin
Standard input is empty
stdout
2.0