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.
 
Ad

Advertisements

Ad

Advertisements

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

Similar Threads

Algorithm 1
Decoding no of ways and printing each decode message 2
BotSavesPrincess Problem 5
INNER JOINING Two Arrays 3
grouping data of array 2
Iterating hashes 11
Parking lot C# 0
sort array 0

Top