I want to decare two Lists: First is a list of Integers. I decare it as:
List<Integer> ints= Arrays.asList(1,2,3);
It works fine.
Second is a list of Objects. I declare it as:
List<Object> objs= Arrays.asList(1,2.13,"three");
But it gives a error in eclipse as soon as I write it. The error is:
Multiple markers at this line
- Type mismatch: cannot convert from List<Object&Comparable<?>&Serializable> to
List<Object>
- Type safety: A generic array of Object&Comparable<?>&Serializable is created for
a varargs parameter
Instead if I write
List<Object> objs = Arrays.<Object>asList(1,2.13,"three");
It works fine.
I am not able figure out the reason.