[Solved] - Concatenate Two String Using Lambda Expressions

CoderIndeed
0

Write a program to concatenate two string using lambda expressions. The lambda expression takes r\two strings as argument and returns the concatenated string. 

Input format
The input consists of two strings.
Output format
The output prints the concatenated strings. 

Sample testcases
Input 1                                          
Hello
World

Output 1
Hello World

import java.util.*;

interface Concatenation
{
    String concat(String str1, String str2);
}

public class Main
{
     public static void main(String[] args) {  
         Concatenation con = (str1,str2)->(str1+str2);
         Scanner inp = new Scanner(System.in);
         // take two string inputs
         String str1 = inp.nextLine();
         String str2 = inp.nextLine();
         
         System.out.println(con.concat(str1,str2));
     }
}

« Go Back

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Accept !