23.11.2017 Views

java_tutorial

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Java<br />

Parameters<br />

Here is the detail of parameters:<br />

<br />

start -- The beginning index, inclusive.<br />

<br />

end -- The ending index, exclusive.<br />

<br />

str -- String that will replace previous contents.<br />

Return Value<br />

<br />

This method returns the modified StringBuffer object.<br />

Example<br />

public class Test {<br />

}<br />

public static void main(String args[]) {<br />

StringBuffer sb = new StringBuffer("abcdefghijk");<br />

sb.replace(3, 8, "ZARA");<br />

System.out.println(sb);<br />

}<br />

This will produce the following result:<br />

abcZARAijk<br />

Here is the list of other methods (except set methods) which are very similar to String<br />

class:<br />

Sr.<br />

No.<br />

Methods with Description<br />

1 int capacity()<br />

Returns the current capacity of the String buffer.<br />

133

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!