Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图从偏好中找到一组长度。我厌倦了 set.length,但它不起作用。有谁知道另一种方法来找到一个集合的长度?
set = prefs.getStringSet("key", null); int X = set.length; //it doesn't like length....
我相信你会想打电话而不是 set.lengthset.size()
set.size()
你的集合是 a Set<String>,而不是 a String[]。所以你必须打电话:
Set<String>
String[]
int x = set.size();