Stephan van Hulst wrote:No. You can also explicitly specify the type of the lambda's parameters:
shambhavi sham wrote:
but if i make the change on line 1 by removing the String generic type, line 6 shows an error ! [/b]
shambhavi sham wrote:
CASE 1 : NO ERROR
List<String> bunnies = new ArrayList<>();
bunnies.removeIf((CharSequence s) -> s.charAt(0) != 'h');
shambhavi sham wrote:
CASE 2 : ERROR
List<CharSequence> bunnies = new ArrayList<>();
bunnies.removeIf((String s) -> s.charAt(0) != 'h'); //error
shambhavi sham wrote:
CASE 3 : ERROR
List bunnies = new ArrayList();
bunnies.removeIf((String s) -> s.charAt(0) != 'h'); //error
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |