How to find the length of the set?

I am trying to find a set item from preference. I am tired of set.length, but it does not work. Does anyone know another way to find the length of the set?

set = prefs.getStringSet("key", null); int X = set.length; //it doesn't like length.... 
+6
source share
2 answers

I believe instead of set.length, you want to call set.size()

+23
source

Your set is Set<String> , not String[] . Therefore you need to call:

 int x = set.size(); 
+3
source

Source: https://habr.com/ru/post/956664/


All Articles