TheBulgarianWolf

Int Array Reader + Output

Apr 25th, 2020
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3.  
  4. public class SoftUni {
  5.    
  6.     public static void main(String[] args) {
  7.         Scanner sc = new Scanner(System.in);
  8.         System.out.print("Enter your numbers here(separated with spaces): ");
  9.         String values = sc.nextLine();
  10.         String[] items = values.split(" ");
  11.         int[] arr = Arrays.stream(items).mapToInt(e -> Integer.parseInt(e)).toArray();
  12.        
  13.         for(int l = 0;l<arr.length;l++){
  14.             System.out.print(arr[l] +  " ");
  15.         }
  16.        
  17.     }
  18.  
  19. }
Add Comment
Please, Sign In to add comment