0
w a java program to enter name i.e. Raja Ram Mohan Rai and print R R M R
4 Réponses
+ 1
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
System.out.println("Type your full name: ");
String fullName=sc.nextLine();
System.out.println("Your short name is: ");
System.out.println(shorten(fullName));
}
private static String shorten(String full){
StringBuilder sb=new StringBuilder();
String[] names=full.split(" ");
for(String name:names){
name=name.toUpperCase();
sb.append(name.charAt(0));
sb.append(" ");
}
return sb.toString();
}
0
no se
0
aaaaaaaahhhhhhhhh
0
Alo