MIT-Curricular/OOP/Java/Lab/Week9/concat_5.java

15 lines
530 B
Java

import java.util.Scanner;
public class concat_5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String concatString = "";
System.out.println("Enter five strings separately:");
for (int i = 1; i<= 5; i++) {
System.out.print("Enter string " + i + ": ");
String inputString = sc.nextLine();
concatString.concat(inputString);
}
System.out.println("Concatenated String: " + concatString);
}
}