Java: Comparing two lists -


मेरे पास दो सूचियां हैं उदाहरण के लिए:

  ए = {21, 41, 96, 02} बी = {21, 96, 32, 952, 1835}  

क्या मैं इच्छित परिणामस्वरूप यह है: आर = {32, 952, 1835}

इसे पसंद करें:

इसके बाद मैं परिणाम R से :

  ए = {21, 41, 96, 02, 32, 952, 1835}  

यह आसान है:)

  सूची & lt; पूर्णांक & gt; ए = नया अर्रेलिस्ट & lt; & gt; (Arrays.asList (21, 41, 96, 02)); सूची के & lt; पूर्णांक & gt; बी = नया अर्रे लिस्ट & lt; & gt; (Arrays.asList (21, 96, 32, 952, 1835)); B.removeAll (a) // अब सूची बी में शामिल हैं (32, 952, 1835) a.addAll (b); // अब इसमें शामिल सूची (21, 41, 96, 02, 32, 9 52, 1835)  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

asp.net mvc - How to attach sql database to a javascript graph -

c# - How to know the number of Threads created and limit the Tasks accordingly -