9

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.

5

3 Answers 3

2

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.

1
  • Looks like it is a long wait, because I still get an error almost exactly like this on the 4.4.1 release a whole year later. lol
    – Hakanai
    Dec 8, 2014 at 23:20
2

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

0

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

(Releases greater or equal P20140317-1600).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.