Explore Courses Blog Tutorials Interview Questions
0 votes
in Java by (7k points)

I am using Java to get string input from the user. I want to make the first letter of this input capitalized.

Can somebody help me with this?

1 Answer

0 votes
by (13.1k points)

You can use .substring() and .toUpperCase() like this:

public static void main(String[] args) throws IOException {

    BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(;

    // Actually use the Reader

    String name = bufferedreader.readLine();

    // Don't mistake String object with a Character object

    String s1 = name.substring(0, 1).toUpperCase();

    String nameCapitalized = s1 + name.substring(1);



Want to learn Java? Check out the Java course from Intellipaat. 

Browse Categories