abstract class java constructor
/**
* Simple Java program to prove that abstract class can have constructor in Java.
* @author http://java67.blogspot.com
*/
public class AbstractConstructorTest {
public static void main(String args[]) {
Server server = new Tomcat("Apache Tomcat");
server.start();
}
}
abstract class Server{
protected final String name;
public Server(String name){
this.name = name;
}
public abstract boolean start();
}
class Tomcat extends Server{
public Tomcat(String name){
super(name);
}
@Override
public boolean start() {
System.out.println( this.name + " started successfully");
return true;
}
}
Output:
Apache Tomcat started successfully
Also in Java:
- java substring
- has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 55.0
- java replace element in list
- split with multiple condition in java
- arraylist in java
- map java
- java convert string with commas to long
- iterate trough linked list java
- update value of an arraylist java
- Java array multidimensional hashcode
- how to detect if someone clicks on a jpanel in java
- java initialize float to zero
- jbutton close jframe java
- int java
- how to remove duplicates from an array java
- java nextpermutation
- how to declare a linked list in java
- How to create a 2d array in java
- javadoc reference general toString
- java remove first character from string
- how to crate a list in java script
- java find if element of list in present in another list
- java hashmap size
- java get last char of string