Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

12.7. SAM Conversions

In Scala, you pass a function as a parameter whenever you want to tell another function what to do. Java does not (currently) have functions, and a Java programmer has to work harder to achieve the same effect. Usually, one puts actions into a class implementing an interface, then gives an instance of that class to another method.

Many times, these interfaces have a single abstract method. They are called SAM types in Java.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial