In  this tutorial, we will see “How to convert an IntStream to an Integer[] in Java 8?” convert intstream to integer array 

Java 8 – Convert IntStream to Integer Array (Integer[]) Share on X

Example. Convert IntStream to Integer Array

/**
 * Convert IntStream to Integer[] 
 * @author Deepak Verma
 *
 */
import java.util.Arrays;

public class Convert_IntStream_To_IntegerArray_Java8_Example {

    public static void main(String[] args) {

        int[] numbers = {1, 2, 3, 4, 5};

        //Following single line converts the IntStream to Integer Array
        Integer[] result = Arrays.stream(numbers).boxed().toArray(Integer[]::new);
        
        System.out.println(Arrays.toString(result));
        
    }

}

 

Output:

[1, 2, 3, 4, 5]

 

Java 8 – Convert IntStream to Integer Array (Integer[]) Share on X
convert intstream to integer array

Do you like this Post? – then check my other helpful posts:

Other Useful References:

Author

  • Deepak Verma

    Deepak Verma is a Test Automation Consultant and Software development Engineer for more than 10 years. His mission is to help you become an In-demand full stack automation tester.

    He is also the founder of Techndeck, a blog and online coaching platform dedicated to helping you succeed with all the automation basics to advanced testing automation tricks.

    View all posts