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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -