What is the correct approach for a utility class having all methods with public static.
Should I use final class or abstract class?
Please give suggestion.
As for example:
public final class A{
public static void method(){
/* ... */
}
}
OR
public abstract class A{
public static void method(){
/* ... */
}
}
abstracthas its own purpose. If you want some of the class functionality implemented by other classes (override) then you use abstract.If it is just utility class, but you don’t want other classes subclass it, then I would go with
finalclass. If utility class has juststaticmethods, any way you can’t override them, so it doesn’t make difference to have them innon-finalclass also.