Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

java 8 book promotion?  RSS feed

 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As am new to java 8 can you provide the real time example of lambda purpose and its inclusion in java 8(play ground)
 
Sheriff
Posts: 11338
177
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

bairava surya wrote:As am new to java 8 can you provide the real time example of lambda purpose and its inclusion in java 8(play ground)


Suppose this simple problem: print all the odd numbers in a list of integers greater than 15 without any duplicates.

In Java 7 you'll probable write something like:

The same code in Java 8:


So you'll see immediately 2 (main) advantages:
  • the Java 8 code is more concise, but it's still easy to read (maybe even better) and the compile-time safety (we all love so much) is still present as well (so the compiler knows i is an Integer)
  • with java 8 you have a well-designed library, so you can concentrate just on what needs to be done. The predicate i -> i > 15 && i % 2 == 1 is the only thing I had to write myself, all the other code is nothing more than using the library


  • And as a final note: let's assume the business requirement changes and duplicates are allowed. In the Java 7 code you have to change Set with List and HashSet with ArrayList; but in the Java 8 code you'll just remove the .distinct() line.

    Hope it helps!
    Kind regards,
    Roel
     
    bairava surya
    Ranch Hand
    Posts: 134
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks for simple program.whats the main usage of embedding javascript with java how it it embedded and is their any interface to do this?
     
    Roel De Nijs
    Sheriff
    Posts: 11338
    177
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    bairava surya wrote:whats the main usage of embedding javascript with java how it it embedded and is their any interface to do this?


    It's not on the OCA 7/8 exam, so we won't elaborate on this new feature in Java 8 in this forum (to avoid confusion for other aspirants preparing for the OCA 7/8 exam). Just start a new thread with your doubts/questions in the SCJP/OCPJP forum.
     
    bairava surya
    Ranch Hand
    Posts: 134
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    As what are some of the strongest concepts that made java 8 most successfull and is java8 can be used in android developing?
     
    Roel De Nijs
    Sheriff
    Posts: 11338
    177
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator

    bairava surya wrote:As what are some of the strongest concepts that made java 8 most successfull


    Without any doubt: lambdas.

    bairava surya wrote:and is java8 can be used in android developing?


    Currently Java 8 is not supported! You can find more info here.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!