title: Filter array elements by length
body: <p>So i want to be able to ask the user to enter the length of an array and fill it with names. After doing so, the program will print out the names with the length of the string next to them.</p>
  
  <pre><code>public static void main(String[] args)
  {
      Scanner sc = new Scanner(System.in);
      String names [];
  
      // Read the number of kids
      System.out.print("How many kids are there? ");
      int size = sc.nextInt();
  
      // Read the names of the kids
      String [] kids = new String [size];
  
      for (int k = 0; k &lt; kids.length; k++)
      {
          System.out.print("Enter name of kid #" + k + ": ");
          kids[k] = sc.next();
      }
      // Print all the names of the kids and the length of their names
      System.out.println("Names of kids with lengths are: ");
  
      for (int i = 0; i &lt; kids.length; i++)
      {
        System.out.println(kids[i] + " " + kids[i].length());
      }
  </code></pre>
  
  <p>after this i want the user to enter an integer and the program will search the array for any strings that are that length, if it finds any i want it to print out the initials of all the ones it finds. I have to use to methods for this program. But i can't seem to wrap my head around this im stuck.</p>
  
  <pre><code>static int countByLength(String [] names, int length)
  {
      int count = 0;
  
  
  
      return count;
  }
  
  
  /**
   * Filter an array of names and keep only those names with a given length
   * @param names: an array of names
   * @param length: an integer length
   * @return the array of names that have the given length
   */
  static String [] filterByLength(String [] names, int length)
  {
      String [] filtered = new String[length];
  
      for(int k = 0; k &lt; filtered.length; k++)
      {
          filtered [k] = 
      }
  
      return filtered; 
  }
  </code></pre>
  
  <p>}</p>