How to capitalize first letter of String Java

By | June 22, 2020

In this article, you will learn how to capitalize first letter of string java. 

Here we have 2 approaches.

1. Use capitalize method of StringUtils

2. Using substring method

 

1. StringUtils.capitalize() method:

This method is coming from apache. It capitalizes the first letter of a string. It will not capitalize any other letter.

Examples:

 

2. Using String substring() method:

Above method extracts first letter of the string and capitalizes it. Then we join the 2nd substring to the 1st substring to get the desired output.

 

Recommended Posts:

Covert String to int in Java

Star pattern programs in Java

Get last 4 chars from String

Timeout test in TestNG

How to clear an arraylist in java

Java interview questions

Real-time selenium interview questions

SQL quick reference for interview preparation

 

Source: http://www.apache.org

Tags: how to capitalize first letter of string java

 

Note: If you like selenium99.com and want to contribute articles, then please send your articles at techygeeks99@gmail.com.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *