Vlad Hatko Vlad Hatko - 9 months ago 58
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 Source

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

You want ClassA.staticProperty.