public class Test{ static int x; StringBuilder sb = new StringBuilder(); static StringBuilder sb2 = new StringBuilder(); public Test() { m1(); m2(); } public void m1(){ x += 5; sb.append(x); } public void m2(){ x += 10; sb2.append(x); } public static void main(String[] args){ Test t1 = new Test(); Test t2 = new Test(); Test t3 = new Test(); String s = t2.sb + "-" + t2.sb2; System.out.println(s); } }