Java Programme to convert CaptialLetters - Ex: hello world and output is hELLO wORLD

 public class StringConversion {


public static String display(String str){
String words[]=str.split("\\s");
String capitalizeWord="";
for(String w:words){
String first=w.substring(0,1);
String afterfirst=w.substring(1);
capitalizeWord+=first+afterfirst.toUpperCase()+" ";
}
return capitalizeWord.trim();
}

public static void main(String[] args) {
System.out.println(display("hello world"));
}
}

output: hELLO wORLD

Comments