Inner Join two Array of integer.

Discussion in 'Java' started by rdj1712, Nov 1, 2017.

  1. rdj1712

    rdj1712

    Joined:
    Nov 1, 2017
    Messages:
    2
    Likes Received:
    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.
     
    rdj1712, Nov 1, 2017
    #1
    1. Advertisements

  2. rdj1712

    John Joe

    Joined:
    Apr 25, 2017
    Messages:
    72
    Likes Received:
    11
    Location:
    Malaysia
    What have you tried ? You can get solution from internet
     
    John Joe, Nov 1, 2017
    #2
    1. Advertisements

  3. rdj1712

    rdj1712

    Joined:
    Nov 1, 2017
    Messages:
    2
    Likes Received:
    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);

    }
    }
     
    rdj1712, Nov 1, 2017
    #3
    John Joe likes this.
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.