0 votes
1 view
in Salesforce by (11.9k points)

public virtual class parent {

    public static void doStuff(){system.debug('stuff');} 

}

public class child extends parent{}

When I call

child.doStuff();

I get this error: Method does not exist or incorrect signature: child.doStuff()

Are static methods not inherited in salesforce or am I doing something wrong?

1 Answer

0 votes
by (31.6k points)

Apex is compatible with Java on this. Static methods are not inherited in a strict sense that means no polymorphism.

So, it is better if you access statics through the class and not an instance. It also produces compiler warnings which are definitely very helpful.

You should access statics through the class, not an instance. It also produces compiler warnings.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...