import org.junit.Test;
public class TestMethods {
@Test
public void test() {
System.out.println("hello world");
}
}
1:首先需要导入import org.junit.test这个jar包,@Test注解要写在你要测试的方法上面
2:然后点击--运行方式,再点击Junit测试,就可以了。
test()方法里面写你需要测试的方法就可以了
---TestMethods这个类不用new,就可以运行。是因为它是通过org.junit.Test中的API中的类反射生成的,然后调用用@Test注解的方法,有几个@Test注解,就运行几个test方法。
一 Lambda表达式:
/**
箭头操作符将Lambda 表达式拆分成两部分:
(x) -> System.out.println(x);
x -> System.out.println(x)
Comparator<Integer> comm = (x,y) -> {
System.out.println("函数式接口");
return Integer.compare(x,y);
};
Comparator<Integer> com = (x,y) ->Integer.compare(x,y);
"类型推断" 写起来方便了,但还是要过类型的检查
Comparator<Integer> com = (Integer x,Integer y) -> Integer.compare(x,y);
可以检查是否是函数式接口
*/
原文:https://www.cnblogs.com/1bing/p/14634593.html