How to use a StringBuffer?
So... I was trying to use this:
Is there any method available to insert a character at a specific position in a string?
For example:
st = "abde" <------ Original string
st= "abCde" <------ Add "C" in position 2
You can use StringBuffer to do this:
String st = new String("abcde");
st = StringBuffer(st).insert(2, "C").toString();
as an example for what I'm trying to do. Basically I just want to add a 1 or a 0 to the end of a pre-existing String. <-binary conversion stuff.
Anyway, so when i try to do it, Eclipse keeps telling me a I need to create a method for StringBuffer(String)..
example..
output = StringBuffer(output).insert("0").toString();
But it should be noted that I've already included: import java.lang.*;
in my code... Help?
Sorry if this seems dumb. I'm extremely new to java and coding in general.