title: Runtime error in Java while testing problem solving. Am i doing the input part wrong on String array?
body: <p><a href="https://i.stack.imgur.com/vOk4y.png" rel="nofollow noreferrer">enter image description here</a>Very simple problem but showing Runtime error on the site(beginner btw). Not so sure about the error, but i think the input part is incorrect(getting multiple strings from input). Is there any other ways to get input on String array? if there is, please let me know.</p>
  <pre><code>Exception in thread &quot;main&quot; java.util.NoSuchElementException: No line found
      at java.base/java.util.Scanner.nextLine(Scanner.java:1651)
      at ExcellentResult.main(ExcellentResult.java:14)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.base/java.lang.reflect.Method.invoke(Method.java:566)
      at _$SandboxExecutor.main(_$SandboxExecutor.java:38)`package examples0;
  </code></pre>
  <pre><code>public static void main(String[] args) {
          Scanner scanner = new Scanner(System.in);
          int n = scanner.nextInt();
          int salary = scanner.nextInt();
          String[] tabs = new String[n];
          int i;
          for(i=0; i&lt;n; i++) tabs[i] = scanner.nextLine();
          for(i=0; i&lt;n; i++){
              switch (tabs[i]) {
                  case &quot;Facebook&quot;:
                      salary-=150;
                      break;
                  case &quot;Instagram&quot;:
                      salary-=100;
                      break;
                  case &quot;Reddit&quot;:
                      salary-=50;
                      break;
              }
          }
          if(salary&gt;0){
              System.out.println(salary);
          }
          else{
              System.out.println(&quot;You have lost your salary.&quot;);
          }
      }
  </code></pre>