java:superHello.HelloJava.java
/** @author Ryome */
/**All about Java programming (encapsulation, inheritance, polymorphism, interface, overload, override,
*List / try-catch / exception / Javadoc)*/
package superHello;
import java.util.Arrays;
class HelloException extends Exception{private static final long serialVersionUID=1L;HelloException(String m){super(m);}}
interface SuperHelloWorld {public abstract String SuperHello() throws HelloException;}
abstract class Hello implements SuperHelloWorld{final String HELLO="Helloworld";private String hello;
Hello(){this.hello=HELLO;}Hello(String hello){this.hello=hello;}public abstract String SuperHello() throws HelloException;
public String getHello(){return hello;}}
class HelloWorld extends Hello {HelloWorld(){super();}@Override public String SuperHello() throws HelloException{return getHello();}}
public class HelloJava{
/**main method@param args not used*/
public static void main(String[] args){
try {Arrays.asList(new HelloWorld().SuperHello()).forEach(System.out::println);}catch(HelloException e){}finally{}
}
}
--Copy the above sentence, specify S-JIS
as the character code, save the folder name as superHello
file name as HelloJava.java
, and execute it. ↓ ↓
-[Easy-to-understand explanation! ] How to use Java instance -[Easy-to-understand explanation! ] How to use Java encapsulation -[Easy-to-understand explanation! ] How to use Java inheritance [Override explanation] -[Easy-to-understand explanation! ] How to use Java polymorphism -[Easy-to-understand explanation! ] How to use Java overload -[Easy-to-understand explanation! ] How to use ArrayList [Java] -[Even beginners can do it! ] How to write Javadoc
Recommended Posts