How do I concatenate two lines dynamically using java?
String s = "HackerRank ";
Scanner scan = new Scanner(System.in);
//Scanner scan = new Scanner(System.in);
String s2 = scan.nextLine();
//concatenates both the strings
s = s+s2;
// s = s.concat(s2);
System.out.println(s);
scan.close();
The output should concatenate two complete lines. for ex. if String s = "Hackerank"
and String s1 = "is very good to learn coding"
,
The output should be like:
Hackerank is very good to learn coding