Advertisement
Methods | Description |
---|---|
public StringBuilder append(String str) | This method appends the String at the end of StringBuilder object. StringBuilder sb= new StringBuilder("Hello"); sb.append("There"); Modifies the StringBuilder object to HelloThere |
public StringBuilder append(int i) | This method appends an int at the end of StringBuilder object. StringBuilder sb= new StringBuilder("High"); sb.append(5); Modifies the StringBuilder object to High5 |
public StringBuilder append(double d) | This method appends a double at the end of StringBuilder object. StringBuilder sb= new StringBuilder("Version"); sb.append(5.0); Modifies the StringBuilder object to Version5.0 |
public StringBuilder append(float f) | This method appends a float at the end of StringBuilder object.. StringBuilder sb= new StringBuilder("Version"); sb.append(5.2f); Modifies the StringBuilder object to Version5.2 |
public StringBuilder append(long l) | This method appends a long at the end of StringBuilder object.. StringBuilder sb= new StringBuilder("Hello"); sb.append("1000L"); Modifies the StringBuilder object to Hello1000 |
public StringBuilder reverse() | This method reverses the string of characters in StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.reverse(); Modifies the StringBuilder object to eulB |
Advertisement
Methods | Description |
---|---|
public StringBuilder delete(int startIndex, int endIndex) | This method deletes the substring starting at index(startIndex)and ending at index(endIndex) in StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.delete(0,2); Modifies the StringBuilder object to ue |
public StringBuilder deleteCharAt(int index) | This method deletes a character at specified index in StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.deleteCharAt(2); Modifies the StringBuilder object to Ble |
public StringBuilder indexOf(String str) | This method returns us the index of the first occurrence of a specified substring(str) in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); int index = sb.indexOf("ue"); Returns the index of ue- 2 |
public StringBuilder lastIndexOf(String str) | This method returns us the index of the last occurrence of a specified substring(str) in the StringBuilder object. StringBuilder sb= new StringBuilder("Blueue"); int lastIndex = sb.lastIndexOf("ue"); Returns the last index of ue- 4 |
public StringBuilder insert(int index, String str) | This method inserts a String(str) at a specfied index in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.insert(0,"Color"); Modifies the StringBuilder object to ColorBlue |
public StringBuilder insert(int index, int i) | This method inserts an int variable at a specfied index in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.insert(1,"5"); Modifies the StringBuilder object to B5lue |
public StringBuilder insert(int index, double d) | This method inserts a double variable at a specfied index in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.insert(1,5.0); Modifies the StringBuilder object to B5.0lue |
public StringBuilder insert(int index, float f) | This method inserts a float variable at a specfied index in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.insert(1,5.5f); Modifies the StringBuilder object to B5.5lue |
public StringBuilder insert(int index, long l) | This method inserts a long variable at a specfied index in the StringBuilder object. StringBuilder sb= new StringBuilder("Blue"); sb.insert(1,555L); Modifies the StringBuilder object to B555lue |
public void setCharAt(int index, char ch) | This method sets a character at an index to specified char(ch). StringBuilder sb= new StringBuilder("Blue"); sb.setCharAt(1,'Z'); Modifies the StringBuilder object to BZue |
public void length() | This method gives us total number of character in StringBuilder Object. StringBuilder sb= new StringBuilder("Blue"); sb.length(); Returns the length of StringBuilder object of - 4 |
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement