converting array to list in java

Java 8Object Oriented ProgrammingProgramming

Following program is converting an Integer[] to List<Integer> −

Example

import java.util.Arrays;
import java.util.List;
public class Tester {
   public static void main(String[] args) {
      Integer[] numbers = {1,2,3,4,5};
      List<Integer> list = Arrays.asList(numbers);
      System.out.println(list);
   }
}

Output

[1, 2, 3, 4, 5]
raja
Published on 06-Feb-2018 12:53:43
Advertisements