Laddie Laddie - 2 years ago 151
Java Question

About public final void

i am a new to java . there is something new pops up called public final void. what does that do ? what is the difference between public static void and public final void? I would be greatly appreciated from guys!

Answer Source
public final void method() {}

This method is final, and so can't be overrided in a subclass.

public static void method() {}

This method is static, and so is class-scoped. You can't use class attribute in this method (unless if they are static), and you call it using MyClass.method() instead of anInstance.method().

Finally, void is the return type of the function (meaning the method returns nothing) and public is an access modifier.

Related questions:

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