Posts

Showing posts from January, 2019

JAVA 8

Java 8 lambdas Why Lambdas? Enables functional programming Readable and concise code - eliminate the boilerplate code Easier-to-use APIs and libraries. Enables Support for parallel processing - Functional Programming read the more readable code or maintainable code Problem in OOPS Everything is an object All code blocks are associated with classes and objects. public class Greeter {  public void greet(){   System.out.println("Hello World");  }  public static void main(String[] args) {   Greeter greeter = new Greeter();   greeter.greet();  } } Output: Hello World Passing Behavior in OOPS The problem of the above program. greet() method always print the "Hello World" message. If you want to print the different message on each time the greet method called. accept the argument. greet() method needs to know what to do. that is not an elegant design. Have an interface as the argument itself and method needs to perform the behavior