Set Length( ) Java Help

Set Length( )

To set the length of the buffer within a String buffer object, use set Length >. Its general form is shown here: void set Length(int well) Here,  specifies the length of the buffer. This value must be non negative. When’ you increase the size of the buffer, null characters arc added to the end of the existing buffer. If you call set Length( ) with a value less than the current value returned by length( ), then the characters stored beyond the new length be lost. The set Char At Demo sample program in the Following section uses set Length( ) to shorten a String Buffer.

Char At( ) and set Char At( )

The value of a single character can be obtained from a String Buffer via the char At( ) method. You can set the value of a character within a String Bluffer using set Char At() . Their general forms are shown here: char char At(int where) void set Char At(int where, char ell), For At(), where specifies the index of the character being obtained’. For. set Char At , fuller specifies the index of the character being set, and clt specifies the ” new value of that character. For both methods; to here must be non negative and must not specify a location beyond the end of the buffer. . The following example demonstrates char At( ) and set Char At( ): Here is ‘the output generated by this program: buffer before  Halo char At {l} before = e buffer after Hi char At().

  • Feel free to send us an inquiry, we will reply back in hours.


Posted on September 17, 2014 in Staring Handling

Share the Story

About the Author

Back to Top