+ 2
Should be clearer
class A { public static void main(String[] args) { B obj = new B(); obj.setV1(50); System.out.println(obj.getV1()); } } class B { private int v1; public void setV1(int x) { this.v1 = x ; } public int getV1() { return v1; } }
1 Resposta
+ 2
Some like this?
class A{
public static void main (String [] x)
B b = new B(50);
System.out.println(b.getV1);
}
}
class B{
private int v1;
B(int v1) {
this.v1 =v1;
}
public int getV1() {
return v1;
}
}