write a program in Java to accept a name containing three words and display only the initial that is first letters of each word
Answers
Answered by
0
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Full Name:");
String userName = sc.nextLine();
String[] words = userName.split("\\s+");
System.out.println(words[0].substring(0, 1) + words[1].substring(0, 1) + words[2].substring(0, 1));
}
}
Similar questions