Java StringBuffer setLength Example
StringBuffer class setLength method example. This example shows you how to use setLength method.
StringBuffer class setLength method example. This example shows you how to use setLength method.Sets the length of the character sequence. The sequence is changed to a new character sequence whose length is specified by the argument.
Here is the cord
/**
* @(#) SetLength. java
* A class representing setLength method
* @Version 01-May-2008
* @author Rose India Team
*/
public class SetLength{
public static void main(String[] args){
// Construct a StringBuffer object:
StringBuffer s = new StringBuffer("Hello world!");
// Change the length of buffer to 5 characters:
s.setLength(5);
System.out.println(s);
}
} |
null
|