public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//write your code here
char[] array = reader.readLine().toCharArray();
array[0] = Character.toUpperCase(array[0]);
for (int i = 1; i < array.length; i++)
{
if(Character.isWhitespace(array[i]))
{
array[i] = Character.toUpperCase(array[i]);
}
}
System.out.print(array);
}
is there any short way to solve this problem....!!!! is there any method to change the first letter of string capital...!! please help any short way
Archived
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
Benjamin Winchester
18 November 2018, 22:02solution
Check out converting a string to a charArray. You can then iterate of each character, test if there is a space preceding it, and capitalize it.
Resource I used.
+5
Learner
16 October 2018, 10:27
You may use Libraries provided for such tasks. For example this.
However, for this task, I think you have to go the old route and build your own logic.
+4