wildcard java solution