This applies to the current instance of the class, not to a specific member.
You want to increase the property (I assume the type is long or int), and not an instance of your increment class (should, by the way, Increment).
Something like this will work:
public class increment {
private int innerValue = 0;
int increment() {
innerValue+=1
return innerValue;
}
public static void main(String[] args) {
increment a = new increment()
System.out.println(a.increment());
}
}
source
share