Why can't a Java class be both abstract and final

前端 未结 6 1484

Suppose I\'ve a utility class which contains only static methods and variables. e.g:

public abstract final class StringUtils
{
    public static final String         


        
6条回答
  •  遥遥无期
    2020-12-16 23:59

    In Java an instance of an abstract class cannot be created, we can only have references of abstract class type. So there if we make abstract class final then we wont be able to extend it. abstract and final are the mutual exclusive concept. that's why Java compiler throws a compile time error when you try to make an abstract class final in Java

提交回复
热议问题