package codesample.java10;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class NewStuffJavaTen {
    public static void main(String[] args) {

        /* Type-inference (Note: does not work for non-local variables, array initializers,
        lambdas (when you create lambda. Returning result into var is OK) */
        var message = "Hello, world!";
        System.out.println(message);

        // Note: This will be array list of Objects
        var empList = new ArrayList<>();

        /* copyOf for collections */
        var list = List.of(1,2,3);
        var copy = List.copyOf(list);

        /* unmodifiable collections on collectors*/
        var set = copy.stream()
                .map(value -> value * 3)
                .collect(Collectors.toUnmodifiableSet());

        /* orElseThrow without arguments throws NoSuchElementException */
        var oneElementList = List.of(5);
        var onlyElement = oneElementList.stream()
                .filter(value -> value > 3)
                .findFirst()
                .orElseThrow();
    }
}

package codesample.java10;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class NewStuffJavaTen {
    public static void main(String[] args) {

        /* Type-inference (Note: does not work for non-local variables, array initializers,
        lambdas (when you create lambda. Returning result into var is OK) */
        var message = "Hello, world!";


        var кукареку = new Кукареку<Кукарек>();

        System.out.println(message);

        // Note: This will be array list of Objects
        var empList = new ArrayList<>();

        /* copyOf for collections */
        var list = List.of(1,2,3);
        var copy = List.copyOf(list);

        /* unmodifiable collections on collectors*/
        var set = copy.stream()
                .map(value -> value * 3)
                .collect(Collectors.toUnmodifiableSet());

        /* orElseThrow without arguments throws NoSuchElementException */
        var oneElementList = List.of(5);
        var onlyElement = oneElementList.stream()
                .filter(value -> value > 3)
                .findFirst()
                .orElseThrow();

        var var = Var.var();
        var.var().var().var().var();

        var listOfInt = new ArrayList<Integer>(List.of(1,2,3));
        var copyy = Collections.unmodifiableList(listOfInt);
        System.out.println(copyy);
        listOfInt.add(4);
        System.out.println(copyy);
    }


    public interface Animal {}
    public interface Cat extends Animal { void meow(); }
    public interface Dog extends Animal { void woof(); }

    void makeSound(Animal animal) {
        var catDog = (Cat & Dog) animal;
        catDog.meow();
        catDog.woof();
    }

    static class Кукареку<T> {

    }

    static class Кукарек {

    }

    public static class Var {
        public static Var var() {
            return new Var();
        }
    }
}

Add new java 10 code
Add new java 10 code
