Lambda
Streams
import java.util.*;
import java.util.stream.*;

public class S
{
	public static void main(String args[])
	{
		int [] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};

		System.out.println("Value: ");
		IntStream.of(array).forEach(e -> System.out.printf("%5d", e));
		System.out.println();

		//Terminal operations
		System.out.println("Min: "+IntStream.of(array).min().getAsInt());
		System.out.println("Max: "+IntStream.of(array).max().getAsInt());;
		System.out.println("Average: "+IntStream.of(array).average().getAsDouble());;
		System.out.println("Sum: "+IntStream.of(array).sum());

		System.out.println("Reduce: "+IntStream.of(array).reduce(0, (x, y) -> x+y));

		//Intermediate operations
		IntStream.of(array).peek(System.out::println).count();
		System.out.println("Filter: "+IntStream.of(array).filter(e -> e%2 == 0).sum());
		IntStream.of(array).map(e -> e*10).forEach(e -> System.out.printf("%5d", e));
		System.out.println();
		IntStream.range(1, 5).forEach(e -> System.out.printf("%5d", e));
		System.out.println();
	}
}
			
import java.util.*;
import java.util.stream.*;

public class L
{
	public static void main(String args[])
	{
		Integer [] array = {2, 9, 5, 0, 3, 7, 1, 4, 8, 6};

		System.out.println(Arrays.asList(array));

		//array to stream
		//stream to List
		System.out.println(Arrays.stream(array).sorted().collect(Collectors.toList()));
	}
}
			
Streams
public class Car
{
	private String maker;

	public Car(String m)
	{
		maker = m;
	}

	public String toString()
	{
		return "Car: "+maker;
	}
}
import java.util.*;

public class L
{
	public static void main(String args[])
	{
		List<Car> l = new ArrayList<Car>();

		l.add(new Car("Buick"));
		l.add(new Car("Honda"));

		l.stream().forEach(System.out::println);
	}
}