How does java find the common parent of a set of objects and construct the corresponding collection?

  1. input: a List < Object >, which may have a variety of objects.
    requires the output: List < T >, where T is the optimal common parent of all elements in the input.
  2. description of the optimal common parent class:
    if the input set contains LinkedList < String > objects and ArrayList < Integer > objects, for them, the optimal common parent class is java.util.AbstractList rather than Object, so the expected output should be a collection of java.util.AbstractList.

how should the above functions be implemented?

Nov.19,2021

the problem is solved in two steps. First of all, the problem is decomposed into several sub-problems to solve the optimal common parent class of several classes, the optimal common parent class of two of them can be found first, and then the optimal common parent class can be obtained by using this common parent class and other classes. by analogy, the optimal common parent class of n classes can be obtained.

how to find the optimal common parent of two classes? This problem can be transformed into finding the first intersection of two one-way linked lists. Think of the inheritance of a class to Object as an one-way linked list. There are many solutions to the problem of one-way linked list intersection, and the subject owner can check it out by himself.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b31f28-2b621.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b31f28-2b621.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?