title: Java - How to execute user input as a method call?
body: <p>I want to be able to type the following into console of my IDE :</p>
  
  <pre><code>reverse("a b c d")
  </code></pre>
  
  <p>But currently I am only able to type </p>
  
  <pre><code>a b c d 
  </code></pre>
  
  <p>How do I achieve this? I have tried using args[0] but I am getting an error.</p>
  
  <pre><code>public static void main(String[] args) {
              Scanner sc = new Scanner(System.in);
              String sentence = sc.nextLine();
              reverse(sentence);
  
          }
          public static void reverse(String s){
                  String [] stringArray;
                  stringArray = s.split(" ");
                  int counter = stringArray.length;
              for (String word : stringArray) {
                  counter -=1;
                  System.out.print(stringArray[counter]+" ");
              }
  
          }
  </code></pre>