Advertisement
Guest User

Untitled

a guest
Mar 20th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Comparator;
  3.  
  4. public class Program {
  5.  
  6. int one, two;
  7.  
  8. Program ( int one, int two ) {
  9. this.one = one;
  10. this.two = two;
  11. }
  12.  
  13. public int getOne() {
  14. return one;
  15. }
  16.  
  17. public int getTwo() {
  18. return two;
  19. }
  20.  
  21. public static void main(String[] args) {
  22.  
  23. ArrayList<Program> array = new ArrayList<Program>();
  24.  
  25. array.add(new Program(1,2));
  26. array.add(new Program(3,4));
  27. array.add(new Program(5,6));
  28. array.add(new Program(7,8));
  29. array.add(new Program(9,10));
  30.  
  31. int min = 0;
  32.  
  33. // for ( Program i : array ) {
  34. // if (i.one > min)
  35. // min = i.one;
  36. // System.out.println(i.one);
  37. // }
  38.  
  39. array.sort(Comparator.comparing(Program::getOne().reverseOrder());
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement