Вопрос

With JEP 101: Generalized Target-Type Inference, this

final List<Boolean> bools = Arrays.asList(true,false, true);
final List<Character> string = bools.stream()
        .<Character>map(x -> x ? 'X' : 'O')
        .collect(Collectors.<Character>toList());

should be reducable to

    final List<Boolean> bools = Arrays.asList(true, false, true);
    final List<Character> string = bools.stream()
            .map(x -> x ? 'X' : 'O')
            .collect(Collectors.toList());

in Java 8, but the latter does not compile:

Type mismatch: cannot convert from List<Object> to List<Character>

Have I got it wrong? Or am I ahead of my tools?

I am using JDK 8 build b120 together with eclipse-SDK-4.3.1-win32-x86_64-efx-0.9.0-SNAPSHOT.zip.

Это было полезно?

Решение 2

Seems like this issue is fixed now with the latest JDT snapshot implementing the desired proposal.

Другие советы

It just works fine under IntelliJ Idea 13 which seems ahead of Eclipse for Java8 support. So I guess you just have to wait until Eclipse will be able to compile this.

The example is accepted by every Eclipse release since the release of Java 8.

(Releases greater or equal P20140317-1600).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top