Vlad Hatko Vlad Hatko - 1 year ago 99
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download