Arrays.asList


#1

Hi

This does not compile:

``

val list : List<BigInteger> = Arrays.asList(BigInteger(“10”), BigInteger(“20”), BigInteger(“30”))

How can I make it compile?

Regards, Etienne


#2

You could try this which is kooler

val list = arrayList(BigInteger("10"), BigInteger("20"), BigInteger("30"))

Whats the compile error on the previous code?


#3

Type mismatch: inferred type is java.util.List<T>? but java.util.List<java.math.BigInteger> was expected


#4

Yeah, most Java APIs by default are of type T? (i.e. that they are nullable). removing the explicit type or using List<BigDecimal?> would fix it


#5

Got it. Thanks, James. (I had interpreted the ? in terms of Java generics...).

Btw, the question mark needs to be outside of the angled brackets.