title: reading input delimited by spaces in java
body: <p>im struggling with the below question.</p>
  
  <p>Question: Input contains the number of blocks n (1 ≤ n ≤ 20) and weights of the blocks w1, …, wn (integers, 1 ≤ wi ≤ 100000) delimited by white spaces. the input should be taken from the user. </p>
  
  <ol>
  <li>how should i write the input with spaces? (lets say my input for no. of blocks is n =5 and the weights of the blocks be : 2 3 55 6 33 - because n=5)</li>
  <li>how should i read the input which are given with white spaces and store it in some list or array ? using what commands.</li>
  </ol>
  
  <p>please find my code:</p>
  
  <pre><code>public static void main(String[] args) {
      int b1 = 0;
      Scanner in = new Scanner(System.in);
      System.out.println("Enter no. of blocks: ");
      b1 = in.nextInt();
      if (b1&lt;=20) {
          in.nextLine();
          int[] arr = new int[b1];
          for (int i=0; i&lt;b1; i++) {
              System.out.println("Enter a weights of ths blocks: ");
              if (arr[i]&lt;=100000) {
            arr[i] = in.nextInt();
  
  
  
  
              }
      }
          }
  </code></pre>
  
  <p>i dont think this is the right way coz the input should be delimited with spaces.. </p>
  
  <p>i was thinking about the ways to proceed but couldnt come up with any solution. can u please help me our on this guys. thanks. </p>