0

**the following program stores values in a 2-D array a[][] and a array "a[]" using a for loop for 5 inputs.while running it takes input only once and skips the input for the following runs and takes no input from the user but it prints the statement **

    for(int i=0;i<5;i++) 
    {
        System.out.println("Enter the name  of Salesman = ");
        name[i]=obj.nextLine();
        System.out.println("Enter the product quantity for " +name[i]);
        for(int j=0;j<5;j++)
        {
            a[i][j]=obj.nextInt();
        }
    }
ΦXocę 웃 Пepeúpa ツ
  • 43,054
  • 16
  • 58
  • 83
  • Does this answer your question? [Scanner is skipping nextLine() after using next() or nextFoo()?](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-or-nextfoo) – OH GOD SPIDERS Sep 07 '20 at 09:30
  • Are you saying that you have a variable ``a[][]`` and a variable ``a[]``? Or am I misreading the question? – NomadMaker Sep 07 '20 at 10:44
  • @NomadMaker i wrote it wrong its names[][] and a[] both are different array – Viraj Malik Sep 08 '20 at 06:25

1 Answers1

0

consume the next line after reading an int

for(int j=0;j<5;j++)
    {
        a[i][j]=obj.nextInt();
    }
ΦXocę 웃 Пepeúpa ツ
  • 43,054
  • 16
  • 58
  • 83