Java8新特性---数组引用

java8新特性—Lambda表达式
java8新特性—方法引用
java8新特性—构造器引用

格式如下:

  • 格式:   type(数组类型)::new
@Test
	public void Test() {
		Function<Integer, String[]> fun1 = (x) ->new String[x];		//使用Lambda表达式
		System.out.println(fun1.apply(10).length);					
		Function<Integer, String[]> fun2 = String[]::new;			//使用数组引用
		System.out.println(fun2.apply(20).length);
	}

猜你喜欢

转载自blog.csdn.net/weixin_43889466/article/details/89234309