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