Inner Join two Array of integer.

Joined
Nov 1, 2017
Messages
2
Reaction score
1
For instance giving two arrays, [1,2,3], [3,3,4], output
[3,4], The implementation must handle
duplicates in either of the input arrays.
 
Joined
Nov 1, 2017
Messages
2
Reaction score
1
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class arraytest{

public static void main(String[] args)
{
Integer[] array1 = { 1,2,3,4};
Integer[] array2 = {3,3,4};


List<Integer> joins = new ArrayList<Integer>(Arrays.asList(array1));
joins.retainAll(Arrays.asList(array2));

System.out.println("Inner Join: " + joins);

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,836
Latest member
BuyBlissBitesCBD

Latest Threads

Top