Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

abstract vs final

1-Abstract method should be overriden
 -Final method can't be overriden
2-Abstract method can be inherited
 -Final can't be inherited
3-Abstract can be w/o implementation
 -Final must have implemetation
4-Abstract we can't create objects
 -Final we can create objects(string)
5-Abstract can't be instantiated
 -Final can be instantiated
Comment

abstract vs final


public final class MyClass { //final not required but clearly states intention
    //private default constructor ==> can't be instantiated
    //side effect: class is final because it can't be subclassed:
    //super() can't be called from subclasses
    private MyClass() {
        throw new AssertionError()
    }

    //...
    public static void doSomething() {}
}

Comment

PREVIOUS NEXT
Code Example
Java :: spigot despawn entity 
Java :: create embeds jda discord 
Java :: java list to set 
Java :: How to convert timestamp to time in java 
Java :: How to efficiently find the highest power of 2 dividing a given number, in Java? 
Java :: java yes or no loop 
Java :: java get current date without time 
Java :: android fragment fullscreen 
Java :: why to use serializable with java bean 
Java :: read double java 
Java :: android videoview setup 
Java :: convert double to in in java 
Java :: border in android 
Java :: java math.random 
Java :: java save file 
Java :: string startswith java 
Java :: java print two dimensional array 
Java :: specify decimal places java 
Java :: replace all punctuation in string java 
Java :: rjava error 
Java :: java array to arraylist 
Java :: sort list of strings java 
Java :: How to perform breadth first search through a binary tree, in Java? 
Java :: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 
Java :: execute code after delay java 
Java :: java selenium send keys number 
Java :: how to iterate a queue in java 
Java :: write a name and convert it to an array 
Java :: initialize hashset with values java 9 
Java :: java array to string 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =