Monday, 8 August 2016

Power of Lambda Expression and Function Programing in Java 8

Functional Programing is the most powerful concept introduced in Java 8. And this can be only achieved by Lambda Expression.

Now, you may get W2H in your mind. Hold on, "W2H" is not any chemistry terminology. I just refer as W2H means (What, Why and How). I mean you are now thinking about "What is Lambdas, Why Lambdas, and How to use Lambdas ?".

Before discussing on Lambdas in details, I just want you to feel the power of it using some examples. Each example here I have prepared with 2 snippet of codes, first is without Java 8 and followed by Java 8 style implementation.

I have a list of employees here with members(id, name, salary, doj, location, dept, permanent/contractor).
Employee{empId='EMP001', name='Mr. Alpha', salary=24000.0, deptName='Product Development', isPermanent=true, doj=Mon Dec 12 00:00:00 IST 2011, location='Chennai'}
Employee{empId='EMP002', name='Mr. Beta', salary=43000.0, deptName='Support', isPermanent=false, doj=Mon Jul 02 00:00:00 IST 2012, location='Chennai'}
Employee{empId='EMP003', name='Mr. Gama', salary=66000.0, deptName='Product Development', isPermanent=false, doj=Mon Dec 30 00:00:00 IST 2013, location='Bangalore'}
Employee{empId='EMP004', name='Mr. Theta', salary=54000.0, deptName='Quality Engineer', isPermanent=true, doj=Wed Sep 12 00:00:00 IST 2012, location='Hyderabad'}
Employee{empId='EMP005', name='Mr. Delta', salary=58000.0, deptName='Support', isPermanent=true, doj=Tue Apr 23 00:00:00 IST 2013, location='Hyderabad'}

These examples are demonstrated the power of Lambda Expression and Functional style of programming. We will discuss in depth how it works for better understanding.  

Stay tuned for more updates.....

No comments:

Post a Comment