24 lines
447 B
Java
24 lines
447 B
Java
|
|
public class InstanceMethods {
|
||
|
|
int value;
|
||
|
|
|
||
|
|
InstanceMethods(int v) {
|
||
|
|
this.value = v;
|
||
|
|
}
|
||
|
|
|
||
|
|
int getValue() {
|
||
|
|
return this.value;
|
||
|
|
}
|
||
|
|
|
||
|
|
void setValue(int v) {
|
||
|
|
this.value = v;
|
||
|
|
}
|
||
|
|
|
||
|
|
public static int main() {
|
||
|
|
InstanceMethods obj = new InstanceMethods(42);
|
||
|
|
System.out.println(obj.getValue());
|
||
|
|
obj.setValue(100);
|
||
|
|
System.out.println(obj.getValue());
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
}
|