The list of methods to do StringJoiner Usage are organized into topic(s).
String
capitalise(String string) Returns a new string consisting of the characters in the specified String, with the first letter of each word capitalised, and the rest lower-case.
String[] words = string.split(" ");
StringJoiner builder = new StringJoiner(" ");
for (String word : words) {
String capitalised = Character.toUpperCase(word.charAt(0)) + word.substring(1).toLowerCase();
builder.add(capitalised);
return builder.toString();
String
convertListToString(String[] stringList) Given a string list, gets the text from the list in the following manner: apple, pear, pineapple
if (stringList == null || stringList.length == 0) {
return "";
StringJoiner stringJoiner = new StringJoiner(", ");
for (String string : stringList) {
stringJoiner.add(string);
return stringJoiner.toString();
...
String
generateDeleteCommand(int deleteDisplayIndex) Generates a delete command at the given displayed index.
StringJoiner commandJoiner = new StringJoiner(" ");
commandJoiner.add("delete").add(String.valueOf(deleteDisplayIndex));
return commandJoiner.toString();
String
getTraceString(StackTraceElement[] stackTraceElements) get Trace String
final StringJoiner sj = new StringJoiner(System.lineSeparator());
for (final StackTraceElement stackTraceElement : stackTraceElements) {
sj.add(stackTraceElement.toString());
return sj.toString();
String
implode(T[] array, String delim) Based on implode() in PHP
final StringJoiner sj = new StringJoiner(delim);
for (T o : array) {
sj.add(o.toString());
return sj.toString();
List
incrementalComputationOfComponentWiseAverage(List average, int n, List newItems) Incrementally calculates component-wise averages, given previously calculated averages (out of n numbers) and a list of new numbers.
if (average == null) {
fatalError("Util.incrementalComputationOfComponentWiseAverage must receive a non-null List");
if (average.size() == 0) {
for (int i = 0; i != newItems.size(); i++) {
average.add(new Double(0));
for (int i = 0; i != newItems.size(); i++) {
double currentAverage = ((Double) average.get(i)).doubleValue();
double newItem = ((Double) newItems.get(i)).doubleValue();
double newAverage = (currentAverage * n + newItem) / (n + 1);
average.set(i, new Double(newAverage));
return average;
String
join(String separator, Collection c) Returns a string formed by the concatenation of string versions of the elements in a collection, separated by a given separator.
Iterator it = c.iterator();
return join(separator, it);