There is no way to make method references unambiguous; simply said, method references are a feature that is just supported for unambiguous method references only. So you have two solutions:
-
use a lambda expression:
Stream.of(1, 32, 12, 15, 23).map(i->Integer.toString(i));
-
(preferred, at least by me) Use a stream of primitive
int
values when the source consists of primitiveint
values only:IntStream.of(1, 32, 12, 15, 23).mapToObj(Integer::toString);
This will use the static
Integer.toString(int)
method for consuming theint
values.