Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #38961

Re: assign lambda to functional interface

Newsgroups comp.lang.java.programmer
Date 2019-05-12 06:28 -0700
References <6594e2c1-ec44-4cbc-b6fb-2c8a852fa7dd@googlegroups.com>
Message-ID <063ded09-67e2-4750-ad8f-7fd00a210861@googlegroups.com> (permalink)
Subject Re: assign lambda to functional interface
From gk <srcjnu@gmail.com>

Show all headers | View raw


On Saturday, May 11, 2019 at 10:28:36 AM UTC+5:30, gk wrote:
> Can we assign a expression into an interface like this ?
> 
> import java.util.function.Predicate;
>  
> public class Main { 
> 	public static void main(String[] args) 
> 	{ 
> 		// Creating predicate 
> 		Predicate<Integer> lesserthan = i -> (i < 18); // is it valid?
> 
> 		// Calling Predicate method 
> 		System.out.println(lesserthan.test(10)); 
> 	} 
> }

Does lambda expression always have to return boolean ?  or lambda can return anything ?
most example shows boolean return by lambda expression. 

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

assign lambda to functional interface gk <srcjnu@gmail.com> - 2019-05-10 21:58 -0700
  Re: assign lambda to functional interface Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-05-11 06:31 -0400
    Re: assign lambda to functional interface gk <srcjnu@gmail.com> - 2019-05-11 05:57 -0700
      Re: assign lambda to functional interface Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-05-11 09:38 -0400
  Re: assign lambda to functional interface gk <srcjnu@gmail.com> - 2019-05-12 06:28 -0700
    Re: assign lambda to functional interface Eric Sosman <esosman@comcast-dot-net.invalid> - 2019-05-12 10:22 -0400

csiph-web