Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ComparableDemo {
- public static void main(String[] args) {
- //Comparable[] a = {"a", "bb", "ccc"};
- //Comparable[] b = {"a","bb","ccc"};
- Comparable[] a = {1, 22, 333};
- Comparable[] b = {1,22,333};
- Integer test = (Integer) equals(a,b);
- System.out.println(test);
- }
- public static Object equals(Comparable[] a, Comparable[] b) {
- Object obj = null;
- for(int i = 0; i < a.length; i++) {
- for(int j = 0; j < b.length; j++) {
- if(a[i].compareTo(b[j]) == 0 && a[i].compareTo(obj) > 0) {
- obj = a[i];
- }
- }
- }
- return obj;
- }
- }
Add Comment
Please, Sign In to add comment