X-Received: by 2002:a37:7986:: with SMTP id u128mr18504687qkc.45.1557667715327; Sun, 12 May 2019 06:28:35 -0700 (PDT) X-Received: by 2002:a0d:e2ca:: with SMTP id l193mr6886340ywe.351.1557667714986; Sun, 12 May 2019 06:28:34 -0700 (PDT) Path: csiph.com!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!c48no1216867qtc.0!news-out.google.com!i13ni21qtr.0!nntp.google.com!c48no1216864qtc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Sun, 12 May 2019 06:28:34 -0700 (PDT) In-Reply-To: <6594e2c1-ec44-4cbc-b6fb-2c8a852fa7dd@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=157.119.105.53; posting-account=0cLATQoAAAAaXjpJ-YnJTFl5IGYMa0vC NNTP-Posting-Host: 157.119.105.53 References: <6594e2c1-ec44-4cbc-b6fb-2c8a852fa7dd@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <063ded09-67e2-4750-ad8f-7fd00a210861@googlegroups.com> Subject: Re: assign lambda to functional interface From: gk Injection-Date: Sun, 12 May 2019 13:28:35 +0000 Content-Type: text/plain; charset="UTF-8" Lines: 17 Xref: csiph.com comp.lang.java.programmer:38961 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 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.