Java:Lambda

来自WHY42
imported>Soleverlee2016年9月26日 (一) 02:52的版本 (以“=Functional Interface= functional interface – an interface with a single abstract method. The Java API has many one-method interfaces such as Runnable, Callable, C...”为内容创建页面)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

Functional Interface

functional interface – an interface with a single abstract method. The Java API has many one-method interfaces such as Runnable, Callable, Comparator, ActionListener and others. They can be implemented and instantiated using anonymous class syntax.

Labmda expression

public interface Hello {
	public void sayHello(String who);
}

public interface Print<T> {
	public void print(T msg);
}

public static void main(String[] args) {
	Hello h = (String s) -> System.out.println(s);
	h.sayHello("Riguz");

	Print<Float> p = (f) -> {
		System.out.println(f);
		System.out.println("Labmda");
	};
	p.print(new Float(3.1415926f));

}

xx