Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    public static List intersection(Object array1[], Object array2[]) {
        ArrayList result = new ArrayList();
        if (array1 != null && array2 != null) {
            for (int i = 0; i < array1.length; i++) {
                Object o1 = array1[i];
                for (int j = 0; j < array2.length; j++) {
                    Object o2 = array2[j];
                    if (o2.equals(o1)) {
                        result.add(o1);
                    }
                }

            }

        }
        return result;
    }
}