I'm trying to use the insertAt method to manipulate String Data using a StringBuffer but I keep getting an error that insertAt is an unrecognized method. Anybody know what I'm doing wrong here?
String strA = "Hello There" ;//initial string value
StringBuffer strBuffer = new StringBuffer(strA);
strBuffer.insertAt(0,"World!");
using insertAt method in javainsertAt to manipulate String data
Page 1 of 1
6 Replies - 6814 Views - Last Post: 04 March 2008 - 09:26 AM
Replies To: using insertAt method in java
#2
Re: using insertAt method in java
Posted 04 March 2008 - 06:10 AM
its simply
public synchronized StringBuffer insert(int offset, Object obj)
#3
Re: using insertAt method in java
Posted 04 March 2008 - 06:43 AM
bhandari, on 4 Mar, 2008 - 06:10 AM, said:
its simply
public synchronized StringBuffer insert(int offset, Object obj)
I still get the same error. its the insertAt method that is causing me all the headache. It should be in the java.lang.String Class but java can't import it for some reason. Any ideas?
#4
Re: using insertAt method in java
Posted 04 March 2008 - 06:46 AM
If i was not clear, its insert and not insertAt
#5
Re: using insertAt method in java
Posted 04 March 2008 - 06:50 AM
#6
Re: using insertAt method in java
Posted 04 March 2008 - 06:53 AM
Please read the explanation of the methods on the JavaDoc website, about StringBuffer and insert.
There is no method called insertAt(int, String) there is only charAt(int), deleteCharAt(int) and setCharAt(int, char) .
There is no method called insertAt(int, String) there is only charAt(int), deleteCharAt(int) and setCharAt(int, char) .
This post has been edited by letthecolorsrumble: 04 March 2008 - 06:55 AM
#7
Re: using insertAt method in java
Posted 04 March 2008 - 09:26 AM
welcome Mideval1. To come back in case of any problem here and spread the word </DIC>
Page 1 of 1

New Topic/Question
Reply



MultiQuote



|