public class StartsWithOfLength implements WordFeature { private char targetChar; private int targetSize; public StartsWithOfLength( char target, int length ) { targetChar = target; targetSize = length; } public boolean hasFeature( String s ) { if ( s == null || s.length() == 0 ) return false; return ( s.charAt(0) == targetChar ) && ( s.length() == targetSize ); } }