Java Reference
In-Depth Information
float
double
There are also append and insert methods that take part of a CharSequence
or char array as an argument. Here is some code that uses various append
invocations to create a StringBuilder that describes the square root of
an integer:
String sqrtInt(int i) {
StringBuilder buf = new StringBuilder();
buf.append("sqrt(").append(i).append(')');
buf.append(" = ").append(Math.sqrt(i));
return buf.toString();
}
The append and insert methods return the StringBuilder object itself, en-
abling you to append to the result of a previous append.
A few append methods together form the java.lang.Appendable interface.
These methods are
public Appendable append(char c)
public Appendable append(CharSequence seq)
public Appendable append(CharSequence seq, int start, int
end)
The Appendable interface is used to mark classes that can receive format-
ted output from a java.util.Formatter objectsee " Formatter " on page
624 .
 
Search WWH ::




Custom Search