Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1.  
  2. public class ComparableDemo {
  3.  
  4. public static void main(String[] args) {
  5. //Comparable[] a = {"a", "bb", "ccc"};
  6. //Comparable[] b = {"a","bb","ccc"};
  7. Comparable[] a = {1, 22, 333};
  8. Comparable[] b = {1,22,333};
  9. Integer test = (Integer) equals(a,b);
  10. System.out.println(test);
  11. }
  12.  
  13. public static Object equals(Comparable[] a, Comparable[] b) {
  14.  
  15. Object obj = null;
  16.  
  17. for(int i = 0; i < a.length; i++) {
  18. for(int j = 0; j < b.length; j++) {
  19. if(a[i].compareTo(b[j]) == 0 && a[i].compareTo(obj) > 0) {
  20. obj = a[i];
  21. }
  22. }
  23. }
  24. return obj;
  25. }
  26. }
Add Comment
Please, Sign In to add comment