
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

public class Util { public static int count( String[] str, int len ) { int ct = 0; for ( int i = 0; i < str.length; i++ ) if ( str[i].length() <= len ) ct++; return ct; } public static String[] lessOrEqual ( String[] str, int len ) { int ct = count( str, len ); String[] result = new String[ct]; // allocate result array int nxt = 0; // next available position for ( int i = 0; i < str.length; i++ ) { if ( str[i].length() <= len ) { result[nxt++] = new String( str[i] ); } } return result; } }