L
L
LittleBob2022-03-13 01:03:40
Java
LittleBob, 2022-03-13 01:03:40

How to convert int array to string with spaces?

You need to convert an int array to a string with a space delimiter. How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Roo, 2022-03-13
@LittleBob

var intArray = new int[]{1, 2, 3};

var string = Arrays.stream(intArray)  // преобразуем массив в IntStream
                .boxed() // преоборазуем IntStream в Stream<Integer>
                .map(String::valueOf) // Integer -> String
                .collect(Collectors.joining(" ")); // собираем в строку с разделителем " "

J
Jacen11, 2022-03-13
@Jacen11

first of all, you don’t need to be stupid and read the rules of the service ; secondly,
literally drive this question into any search engine
https://yandex.ru/search/?text=java+%D0%9A%D0%B0%D...
and there already you can choose any method from a dozen

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question