Inner Join two Array of integer.

Joined
Oct 31, 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
Oct 31, 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
474,265
Messages
2,571,069
Members
48,771
Latest member
ElysaD

Latest Threads

Top