File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ package  com .javatechie .lambda .demo ;
2+ 
3+ interface  Calculator  {
4+ 
5+ 	// void switchOn(); 
6+ 
7+ 	/* void sum(int input); */ 
8+ 
9+ 	int  substract (int  i1 , int  i2 );
10+ }
11+ 
12+ public  class  CalculatorImpl  {
13+ 
14+ 	public  static  void  main (String [] args ) {
15+ 
16+ 		/* 
17+ 		 * Calculator calculator = () -> System.out.println("Switch On"); 
18+ 		 *  
19+ 		 * calculator.switchOn(); 
20+ 		 */ 
21+ 
22+ 		/* 
23+ 		 * Calculator calculator = (input) -> System.out.println("Sum : " + input); 
24+ 		 * calculator.sum(394); 
25+ 		 */ 
26+ 
27+ 		Calculator  calculator  = (i1 , i2 ) -> {
28+ 			if  (i2  < i1 ) {
29+ 				throw  new  RuntimeException ("message" );
30+ 			} else  {
31+ 				return  i2  - i1 ;
32+ 			}
33+ 		};
34+ 
35+ 		System .out .println (calculator .substract (8 , 20 ));
36+ 	}
37+ 
38+ 	// () -> {body}; 
39+ }
Original file line number Diff line number Diff line change 1+ package  com .javatechie .lambda .demo ;
2+ 
3+ public  interface  MyFunctionalInterface  {
4+ 
5+ 	void  m1 ();
6+ 
7+ 	default  void  m2 () {
8+ 		System .out .println ("Default method-1" );
9+ 	}
10+ 
11+ 	default  void  m3 () {
12+ 		System .out .println ("Default method-2" );
13+ 	}
14+ 
15+ 	static  void  m4 () {
16+ 		System .out .println ("static method-1" );
17+ 	}
18+ }
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments