SoFunction
Updated on 2025-03-01

Java method to get different data in two arrays

This article example describes the method of java to obtain different data in two arrays. Share it for your reference. The specific implementation method is as follows:

public static <T> List<T> compare(T[] t1, T[] t2) {
    List<T> list1 = (t1);
    List<T> list2 = new ArrayList<T>();
    for (T t : t2) {
      if (!(t)) {
        (t);
      }
    }
    return list2;
}
compare(new Integer[] { 1, 2, 3 }, new Integer[] {1, 2, 3, 4 })

I hope this article will be helpful to everyone's Java programming.