Using the Java Collections Disjoint Method

Using the Java Collections Disjoint Method

See how to use the disjoint method in Collections to find if the given lists are completely disjointed:

import java.util.*;public class UsingDisjointInCollections {      public static void main(String args[])   {      UsingDisjointInCollections usingDisjointInCollections = new UsingDisjointInCollections();      usingDisjointInCollections.proceed();   }      private void proceed()   {      //Creating 2 lists to compare      List firstLst = new ArrayList(3);      List secondList = new ArrayList(3);      //Populating the first list with some elements      firstLst.add("It");      firstLst.add("is");      firstLst.add("raining");      //Populating the second list with some elements            secondList.add("Its cool");      secondList.add("weather");      secondList.add("after");      secondList.add("raining");            //Using disjoint, checking both the lists      boolean areListsDisjoint = Collections.disjoint(firstLst, secondList);      System.out.println("Given lists are disjoint: "+areListsDisjoint);       }    }/*Expected output:[[email protected]]# java UsingDisjointInCollectionsGiven lists are disjoint: false*/ 
Share the Post:
data observability

Data Observability Explained

Data is the lifeblood of any successful business, as it is the driving force behind critical decision-making, insight generation, and strategic development. However, due to its intricate nature, ensuring the

Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved