Answers for "firstname+lastname from 2 different arrays"

0

firstname+lastname from 2 different arrays

Scanner sc = new Scanner(System.in);
    String[] first = new String[5];
    String[] last = new String[5];
    System.out.print("Enter 5 first name: ");
    for(int i=0; i<5; i++){
        first[i]=sc.nextLine();
    }
    System.out.print("Enter 5 last name: ");
    for(int i=0; i<5; i++){
        last[i]=sc.nextLine();
    }
    String joinedString = String.join(first, last);
    System.out.println(joinedString);
Posted by: Guest on March-17-2022
0

firstname+lastname from 2 different arrays

Scanner sc = new Scanner(System.in);
String[] first = new String[5];
String[] fullName = new String[5];
System.out.print("Enter 5 first name: ");
for(int i=0; i<5; i++){
    first[i]=sc.nextLine();
}
System.out.print("Enter 5 last name: ");
for(int i=0; i<5; i++){
    fullName[i]=first[i]+" "+sc.nextLine());
}
for(int i=0; i<5; i++){
    System.out.println(fullName[i]);
}
Posted by: Guest on March-17-2022

Code answers related to "firstname+lastname from 2 different arrays"

Browse Popular Code Answers by Language