1

Today i experienced a strange error. The Strange was if i add the below code block in eclipse IDE it shows no error , but the same piece of code i compile it from cmd its showing error as

inference variable R has incompatible bounds

The Code Piece as follows:

import java.util.*;
import java.util.stream.*;
import java.util.function.*;
public class Test{

    public static void main(String[] args){
        int[] x = {1,2,3,4,5,6,1,2,3,1,4,65,3,56,24};
        System.out.println(Arrays.stream(x).boxed().collect(Collectors.groupingBy(Function.identity(),LinkedHashMap::new,Collectors.counting())));
    }
}

I Used same JDK versions(11.0.15 2022-04-19 LTS) both in eclipse as well as cmd prompt to compile it. Is Eclipse is doing some magic here or it is a bug at eclipse IDE.

Holger
  • 285,553
  • 42
  • 434
  • 765
user3309305
  • 181
  • 1
  • 7
  • 1
    Java 19 javac still complains. Strangely moving the code out of the println and assigning to a variable makes it work. Note that Eclipse uses its own compiler which is why you may ocassionally get different results. – greg-449 Sep 23 '22 at 06:28
  • 2
    The problem is that `println` is overloaded. So it’s the same bug as in [this Q&A](https://stackoverflow.com/q/32223890/2711488). Introduced somewhere around Java 8, update 60. – Holger Sep 23 '22 at 08:02

0 Answers0