0
function ClosureFunc(x){
     return function(y){
           retrun  x + "and" + y;
     };
}

I'm not used to coding javascript's expression and unique characteristics. And I have experience Java Object-Oriented concept. So this function seems a little bit awkward to me. How can it be transformed when I use java code?

JongHyeon Yeo
  • 879
  • 1
  • 10
  • 18
  • can a java function return a function? – Jaromanda X Feb 09 '18 at 01:46
  • Function closureFunc(final String x) { return y -> x + "and" + y; } – raner Feb 09 '18 at 01:50
  • 1
    @JaromandaX Java does not have function, there are methods. In Java, we can return behaviour, and pass methods as parameter to other methods, so yes java supports closures from v1, they are called anonymous classes. In Java 8, we have a syntactical sugar called lambda in place of anonymous class with a single behaviour. – Aniket Sahrawat Feb 09 '18 at 01:59
  • @AniketSahrawat - semantics – Jaromanda X Feb 09 '18 at 02:04

0 Answers0