How to check if HashSet is empty in Java

1 Answer

0 votes
import java.util.*;

public class MyClass {
    public static void main(String args[]) {
        Set<String> letters = new HashSet<>(Arrays.asList("a", "b", "c", "d", "a", "a", "e"));
      
        System.out.println(letters.isEmpty()); 
    }
}




/*
run:

false

*/

 



answered Feb 16, 2021 by avibootz

Related questions

1 answer 159 views
159 views asked Nov 30, 2016 by avibootz
1 answer 183 views
1 answer 212 views
1 answer 231 views
2 answers 197 views
1 answer 206 views
...