title: How to make arrayList read Strings only but not int?
body: <blockquote>
    <p>Write a method called countWords that accepts an ArrayList of String as argument and
    prints out the number of words (i.e. Strings) that start with ―A‖ or ―a‖ and prints all words longer than 5 characters on one line.</p>
  </blockquote>
  
  <p>My solution is like </p>
  
  <pre><code>int count=0;
      String[] st=null;
  
      Scanner input=new Scanner(System.in);
      ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt;();
      System.out.println("please input something");
  
  while(input.hasNext()) {
          String st1=input.next();
          array.add(st1);
  
      }
  
  
      for(int i=0; i&lt;array.size();i++) {
          if(array.get(i).startsWith("a")||array.get(i).startsWith("A")) {
              count++;
          }
      }
          for(int j=0; j&lt;array.size(); j++) {
              if(array.get(j).length()&gt;5) 
                  st[j]=array.get(j);
  
          }
  
          System.out.println(count);
          System.out.println(st);
  }
  </code></pre>
  
  <p>but there will be no end for typing in Strings</p>