Easiest way to convert String to StringBuffer
Im looking a way to easily convert String to StringBuffer for passing it to different methods.
If it were the other way, I would use
However, I have method that takes StringBuffer as an argument, but my variable is String.
Right now I'm doing
Is there any simple way to cast String -> StringBuffer without needing to write those needless lines of code?
String str = "Hello Java-forums.org";
/* This is where it goes kinda complicated and messy */
StringBuffer sb = new StringBuffer(str);