Class StringFormatter
java.lang.Object
it.unimi.di.prog2.h14.StringFormatter
A class to collect a sequence of strings and format them.
This class collects strings and nulls and can return the sequence both via toString() that concatenates non-null strings with a space, inserting a newline for each
null, and via an iterator that returns just the non-null strings.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a string, or null, to the formatter.iterator()Returns an iterator over the non-null strings in this formatter.toString()Returns a string version of this formatter, non-null strings will be concatenated with a space, and a newline will be inserted for each null.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Iterable
forEach, spliterator
-
Field Details
-
string
-
-
Constructor Details
-
StringFormatter
public StringFormatter()Creates an empty formatter.
-
-
Method Details
-
add
Adds a string, or null, to the formatter.- Parameters:
s- the string to add, or null.
-
toString
-
iterator
-