Vlad Hatko Vlad Hatko - 17 days ago 6
Java Question

Reference to class inside static func

I have class A:

public class ClassA {
private static int staticProperty;

public static void setStaticProperty(int staticProperty) {
//this.staticProperty = staticProperty
}
}


how can I refer to class here? uncommented code doesn't work.

I can rename property, though, but I'm wondering in possibility of such referring at all.

Answer

this is an instance; you don't have an instance.

You want ClassA.staticProperty.