/** *Splitsastringaroundthegivencharacter.Thearrayreturnedbythis *methodcontainseachsubstringthatisterminatedbythecharacter.Use *forsimplestringspiltingcaseswhenneedingtoavoidloadingregex.
*/ static String[] split(String s, char c) { int count = 0; for (int i=0; i<s.length(); i++) { if (s.charAt(i) == c)
count++;
}
String[] result = new String[count+1]; int n = 0; int last = 0; for (int i=0; i<s.length(); i++) { if (s.charAt(i) == c) {
result[n++] = s.substring(last, i);
last = i + 1;
}
}
result[n] = s.substring(last, s.length()); return result;
}
/** *ReturnsaSetcontainingthegivenelements.
*/
@SafeVarargs static <E> Set<E> newSet(E... elements) {
HashSet<E> set = new HashSet<>(); for (E e: elements) {
set.add(e);
} return set;
}
/** *ReturnsaSetcontainingalltheelementsofthegivenSetplus *thegivenelements.
*/
@SafeVarargs static <E> Set<E> newSet(Set<E> other, E... elements) {
HashSet<E> set = new HashSet<>(other); for (E e: elements) {
set.add(e);
} return set;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.