title: Inserting values into two array using scanner class in java
body: <pre><code>import java.util.Scanner;
  public class Demo3 
  {
      public static void main(String[] args)
      {
          Scanner scan = new Scanner(System.in);
          System.out.print("Enter how many friends: ");
          int numOfFriends = Integer.parseInt(scan.nextLine());
          String arrayOfNames[] = new String[numOfFriends];
          long income[] = new long[numOfFriends];
          for (int i = 0; i &lt; arrayOfNames.length; i++) 
          {
              System.out.print("\nEnter the name of friend " + (i+1) + " : ");
              arrayOfNames[i] = scan.nextLine();
              for(int j = 0; j&lt;arrayOfNames.length;j++)
              {
                  System.out.print("\nEnter the income of friend " + (j+1) + " : ");
                  income[j] = scan.nextLong();
              }
          }
      }
  }
  </code></pre>
  
  <p>This is my code, I want to take input name from user then the income of that person then again the name of another person
  The above code is not arranged properly, I think there's problem in the for loop the sample output should be like:</p>
  
  <pre><code>Enter how many friends: 2
  Enter name of friend 1 : #############
  Enter income of friend 1 : ############## 
  Enter name of friend 2 : #############
  Enter income of friend 2 : ##############
  </code></pre>