Inserting array elements in mp
for ( int i = 0 ; i < n ; i ++ ) { mp . put ( a [ i ] , i ) ; } for ( int i = 0 ; i < m ; i ++ ) { mp . put ( b [ i ] , i ) ; } System . out . println ( " The ▁ union ▁ set ▁ of ▁ both ▁ arrays ▁ is ▁ : " ) ; for ( Map . Entry mapElement : mp . entrySet ( ) ) { System . out . print ( mapElement . getKey ( ) + " ▁ " ) ; } }