How to left trim a String in Java : Source code with example

To remove the unnecessary left  spaces in the beginning of the word  ,also known as left trimming of the word.
Java provides the built in method to left trim the word . But here we are writing the code without using the built in method of java .
for example :
If the user inputs a string like this :  "   Alive is awesome" , then the result will remove the spaces before the first character of the word .
So the answer will be : "Alive is awesome"

Demo :

left trim string java code

About The Author

Subham Mittal has worked in Oracle for 3 years .
For more java articles ,Click here to Subscribe JavaHungry