Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.HashSet; public class JavaCollectionEqualsExample2 { public static void main(String[] args) { Collection
collection = new HashSet<>(); Collection
collection1 = new HashSet<>(); collection.add(5); collection1.add(5); collection1.add(8); //will return true if both the collections are equal boolean val=collection.equals(collection1); System.out.println("Equals methods will return : "+val); } }
Output