Write a Java program to convert first character uppercase in a sentence and if apart from first character if any character is in Uppercase then convert in into Lowercase?
Input : gEEKs Output :Geeks Input :GFG Output :Gfg
Geeks For Geeks
Method 2: Using Java Inbuilt methods
To capitalize each word, call the
toLowerCase() method to put the string in lowercase format. Iterate the string, if any space if found in previous iteration and current element is not space then call the
toUpperCase() method to put the first letter of word in uppercase format and append the string in buffer.
Below is the implementation:
- Java Program to convert Character Array to IntStream
- Convert a String to Character array in Java
- Java program to count the characters in each word in a given sentence
- Java program to swap first and last characters of words in a sentence
- Program to print ASCII Value of a character
- Java Program to get a character from a String
- Java program to count the occurrences of each character
- Java program to count the occurrence of each character in a string using Hashmap
- Program to Convert List to Map in Java
- Program to convert a Map to a Stream in Java
- Program to convert Array to Set in Java
- Program to Convert Set to List in Java
- Program to Convert Radian to Degree
- Program to Convert Stream to an Array in Java
- Program to convert set of String to set of Integer in Java
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.