title: When i run my code, after inputting a number it doesnt let me input a string, and it goes ahead
body: <p>when i input the number it just moves ahead without letting me enter the string and shows an output
  when i use sc.next();, it does not go forward without the string, but i want to use sc.nextLine(), but it is not working</p>
  <pre><code>public class project1
  {
      public static void main()
      {
          Scanner sc = new Scanner(System.in);
          int n;
          char a;
          System.out.println(&quot;Enter \n 1 for counting the total number of vowels in it \n 2 for printing the first letter of each word in a string&quot;);
          n = sc.nextInt();
          switch(n)
          {
              case 1:
              int count = 0;
              System.out.println(&quot;Input a string&quot;);
              String str = sc.nextLine();
              str = str.toLowerCase();
              for(int i = 0; i &lt; str.length(); i++)
              {
                  a = str.charAt(i);
                  if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
                  count++;
              }
              System.out.println(&quot;There are &quot;+ count +&quot; vowels in the string.&quot;);
              break;
              
              case 2:
              System.out.println(&quot;Input a string&quot;);
              String str2 = sc.nextLine();
              System.out.println(&quot;First letter of each word:&quot;);
              for(int i = 0; i &lt; str2.length(); i++)
              {
                  a = str2.charAt(i);
                  if(a == ' ')
                  System.out.print(str2.charAt(i+1) + &quot;, &quot;); 
              }
              break;
          }
      }
  }
  </code></pre>