انشاء واجهة عامة الاستعمال Java 50- Generic interface
package package3;public interface Generic<T>{public static final double PI=3.14;public T method4();private void method1(){System.out.println("I m private 1");}default void method2(){method1();}static void method3(){System.out.println("I m static 1");}}------------------------------------------package package2;import package3.Generic;public class Apps<T> implements Generic<T>{T obj;public T getObj() {return obj;}public void setObj(T obj) {this.obj = obj;}public Apps(T obj) {this.obj = obj;}@Overridepublic T method4() {return null;}}----------------------------------package package3;public class Apple{public static void main(String... args) {Generic<String> generic= ()->{ return " I m functional interface";};System.out.println(generic.method4());}}-------------affiche : I m functional interface
0 تعليقات