Module 51
Module 51
ENUMERATIONS
ENUMERATION FUNDAMENTALS
• Ex
}
}
• setLength( )
– To set the length of the buffer within a
StringBuffer object, use setLength( ). Its general
form is shown here:
• void setLength(int len)
charAt( ) and setCharAt( )
– The value of a single character can be obtained from a
StringBuffer via the charAt( ) method.
• You can set the value of a character within a StringBuffer
using setCharAt().
• Their general forms are shown here: char charAt(int
where)
• void setCharAt(int where, char ch)
Example:
• StringBuffer sb = new StringBuffer("Krishna");
sb.charAt(2)// selects i
• sb.setCharAt(2, “u‘)// sets second index value to u means
krushna
insert( )
– The insert( ) method inserts one string into another. It is overloaded to accept
values of all the simple types, plus Strings, Objects, and CharSequences.
These are a few of its forms:
• StringBuffer insert(int index, String str)
Example:
class insertDemo {