Instead of recording
StringBuilder demo = new StringBuilder("Hello");
it is simpler and you do not need to allocate a StringBuilder for it:
String demo = "Hello";
If you use a method that means it must be a StringBuilder, the warning should disappear.
eg.
StringBuilder demo = new StringBuilder("Hello");
demo.append(" World ");
demo.append(128);
source
share