I have two lists of 50 numbers.
One has multiples of 3
and the other multiples of 7
.
Code:
public static void main(String[] args) {
List<Long> lista1 = new ArrayList<>();
List <Long> lista2 = new ArrayList<>();
for (long a = 1; a <= 50; a++) {
long b,c;
b = a*3;
c = a*7;
lista1.add(b);
lista2.add(c);
}
System.out.println("Lista(1)="+lista1);
System.out.println("Lista(2)="+lista2);
}
}
See working on repl: link
I need only the numbers that repeat between the two lists to be printed, thus only:
List (3) = [21, 42, 63, 84, 105, 126, 147]