java - Can you equalsIgnoreCase a Set? -
java - Can you equalsIgnoreCase a Set? -
so, have program, , users target in set called 'computer'. user enters in 'computer', 'computer','computer', never finds because it's not capitalized correctly.
how go taking set words = ... ... ... , taking info within of set , checking if equal 'computer', ignoring capitalization. oooor! making else lowercase, first character.
example code:
set<string> words= this.getconfig().getconfigurationsection("test").getkeys(false); if( allgroups.contains('computer') ) {
please ignore this.getconfig().getconfigurationsection("test").getkeys(false);. looking reply prepare minecraft plugin i'm making, seems more basic java knowledge question.
thank help guys
you perchance utilize treeset
because sorts input can take comparator. using implement behaviour want. like
comparator<string> comparator = new comparator<string>() { @override public int compare(string o1, string o2) { if (o1 == o2) { homecoming 0; } if (o1 == null) { homecoming -1; } else if (o2 == null) { homecoming 1; } homecoming o1.tolowercase().compareto(o2.tolowercase()); } }; set<string> set = new treeset<>(comparator);
or (from comments) string.case_insensitive_order
like
set<string> set = new treeset<>(string.case_insensitive_order);
java set
Comments
Post a Comment