24 lines
447 B
Java
Raw Normal View History

2025-12-02 06:54:32 +01:00
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;
}
}