/** * Returns this String sequence as an array of Strings. Subclasses may provide a more efficient * implementation than the one provided here. * * @return An array containing exactly this sequence of Strings */ public String[] toArray() { // Get number of Strings final int size = size(); // Allocate array final String[] strings = new String[size]; // Copy string references for (int i = 0; i < size; i++) { strings[i] = get(i); } return strings; }
/** * Joins this sequence of strings from first index to last using a separator * * @param first * The first index to use, inclusive * @param last * The last index to use, exclusive * @param separator * The separator to use * @return The joined String */ public final String join(final int first, final int last, final String separator) { // Allocate buffer of exactly the right length final int length = totalLength() + (separator.length() * (Math.max(0, last - first - 1))); final AppendingStringBuffer buf = new AppendingStringBuffer(length); // Loop through indexes requested for (int i = first; i < last; i++) { // Add next string buf.append(get(i)); // Add separator? if (i != (last - 1)) { buf.append(separator); } } return buf.toString(); }
/** * Joins this sequence of strings using a comma separator. For example, if this sequence * contains [1 2 3], the result of calling this method will be "1, 2, 3". * * @return The joined String */ public final String join() { return join(", "); }
/** * Joins this sequence of strings from first index to last using a separator * * @param first * The first index to use, inclusive * @param last * The last index to use, exclusive * @param separator * The separator to use * @return The joined String */ public final String join(final int first, final int last, final String separator) { // Allocate buffer of exactly the right length final int length = totalLength() + (separator.length() * (Math.max(0, last - first - 1))); final AppendingStringBuffer buf = new AppendingStringBuffer(length); // Loop through indexes requested for (int i = first; i < last; i++) { // Add next string buf.append(get(i)); // Add separator? if (i != (last - 1)) { buf.append(separator); } } return buf.toString(); }
/** * Converts this object to a string representation * * @return String version of this object */ public String toString() { return "[" + join() + "]"; } }
/** * Returns this String sequence as an array of Strings. Subclasses may provide a more efficient * implementation than the one provided here. * * @return An array containing exactly this sequence of Strings */ public String[] toArray() { // Get number of Strings final int size = size(); // Allocate array final String[] strings = new String[size]; // Copy string references for (int i = 0; i < size; i++) { strings[i] = get(i); } return strings; }
/** * Joins this sequence of strings from first index to last using a separator * * @param first * The first index to use, inclusive * @param last * The last index to use, exclusive * @param separator * The separator to use * @return The joined String */ public final String join(final int first, final int last, final String separator) { // Allocate buffer of exactly the right length final int length = totalLength() + (separator.length() * (Math.max(0, last - first - 1))); final AppendingStringBuffer buf = new AppendingStringBuffer(length); // Loop through indexes requested for (int i = first; i < last; i++) { // Add next string buf.append(get(i)); // Add separator? if (i != (last - 1)) { buf.append(separator); } } return buf.toString(); }
/** * Joins this sequence of strings using a comma separator. For example, if this sequence * contains [1 2 3], the result of calling this method will be "1, 2, 3". * * @return The joined String */ public final String join() { return join(", "); }
/** * Returns this String sequence as an array of Strings. Subclasses may provide a more efficient * implementation than the one provided here. * * @return An array containing exactly this sequence of Strings */ public String[] toArray() { // Get number of Strings final int size = size(); // Allocate array final String[] strings = new String[size]; // Copy string references for (int i = 0; i < size; i++) { strings[i] = get(i); } return strings; }
/** * Joins this sequence of strings using a comma separator. For example, if this sequence * contains [1 2 3], the result of calling this method will be "1, 2, 3". * * @return The joined String */ public final String join() { return join(", "); }
/** * Converts this object to a string representation * * @return String version of this object */ @Override public String toString() { return "[" + join() + "]"; } }
/** * Converts this object to a string representation * * @return String version of this object */ @Override public String toString() { return "[" + join() + "]"; } }
/** * Returns this String sequence as an array of Strings. Subclasses may provide a more efficient * implementation than the one provided here. * * @return An array containing exactly this sequence of Strings */ public final List<String> toList() { // Get number of Strings final int size = size(); // Allocate list of exactly the right size final List<String> strings = new ArrayList<>(size); // Add strings to list for (int i = 0; i < size; i++) { strings.add(get(i)); } return strings; }
/** * Returns this String sequence as an array of Strings. Subclasses may provide a more efficient * implementation than the one provided here. * * @return An array containing exactly this sequence of Strings */ public final List toList() { // Get number of Strings final int size = size(); // Allocate list of exactly the right size final List strings = new ArrayList(size); // Add strings to list for (int i = 0; i < size; i++) { strings.add(get(i)); } return strings; }