java8特性表达式
public static void main(String[] args) {
JFrame jframe = new JFrame("My JFrame");
JButton jButton = new JButton("My JButton");
///表达式写法:如果有多行就加中括号,一行不用加
jButton.addActionListener(event -> {
System.out.println("Button Pressed!");
System.out.println("hello world");
System.out.println("executed");
});
jframe.add(jButton);
jframe.pack();
jframe.setVisible(true);
jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
/**
*lambda表达式基本结构:
*{param1,param2,param3}->{}
*
*
*/
...
package rm;
@FunctionalInterface
public interface Myinterface {
void test();
String toString();
//如果一个接口声明了抽象方法,但是抽象方法重写父类方法,
// 是不会向接口数量加一的,。
}
class Test2{
public void myTest(Myinterface my){
System.out.println(1);
my.test();
System.out.println(2);
}
public static void main(String[] args) {
Test2 test2 = new Test2();
test2.myTest(()->{
System.out.println("mytest");
});
}
}
....
---------------------------------------------------------------------------
国之殇,未敢忘!
南京大屠杀!
731部队!
(有关书籍《恶魔的饱食》)以及核污染水排海等一系列全无人性的操作,购买他们的食品和为它们提供帮助只会更加变本加厉的害你,呼吁大家不要购买日本相关产品
昭昭前事,惕惕后人
吾辈当自强,方使国不受他人之侮!
---------------------------------------------------------------------------
作者:三号小玩家
出处:https://www.cnblogs.com/q1359720840/
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。 版权信息

浙公网安备 33010602011771号