This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Dynamic list comparison Java

I want to compare a dynamic set of lists. For example, I have a set of species(A,B,C) (this set of species is dynamic i.e. the length can be more) Each specie has a set of genes. e.g A = {gene a, gene b, gene c}, B = {gene a, gene b, gene d, gene e}, C = {gene a}. This set can be dynamic. I want to compare the set of genes to extract the common genes amongst these list.

What is the best way to solve this problem and how to create dynamic lists in Java?

Thank you.

gene

1 answer

In python:

A=[a,b,c]

B=[a,b,d,e]

...

set(A) & set(B) & set(C)

in Java check out the Set interface and specifically the retainAll method

Log in to answer this question.