Do you want this?
public class AppendOperation() { private static StringBuilder sb = new StringBuilder(); public static StringBuilder append(String s){ return sb.append(s); } public static void main(String... args){ System.out.println(AppendOperation.append("ada").append("dsa").append("asd")); } }
Perhaps I do not understand the question (static context) correctly
Do you mean this?
static {
} // Of course you can do it too
If not all of the above, you cannot do without any static method, because append () is not static
user467871
source share