Like I have such code:
class myobj {
public static int i;
public myobj(int _i) {
i = _i;
}
}
public class mainclass {
public static void main(String[] args) {
myobj a = new myobj(1);
myobj b = new myobj(2);
System.out.println(b.i); // Prints 2 - expected
System.out.println(a.i); // Prints 2 - unexpected
}
}
And I want a.i
to be 1.
How can I make a 'new' object?