Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert strings between uppercase and lowercase in Java?

Tags:

java

string

What is the method for converting strings in Java between upper and lower case?

like image 693
Nanda Avatar asked Dec 23 '09 10:12

Nanda


People also ask

How do I convert a string to lowercase in java?

The toLowerCase() method converts a string to lower case letters. Note: The toUpperCase() method converts a string to upper case letters.

What is the difference between toUpperCase () and toLowerCase ()?

The toLowerCase operator takes a string and converts it to all lower case letters. The toUpperCase operator takes a string and converts it to all uppercase letters.


2 Answers

String#toLowerCase and String#toUpperCase are the methods you need.

like image 120
PeterMmm Avatar answered Oct 08 '22 17:10

PeterMmm


There are methods in the String class; toUppercase() and toLowerCase().

i.e.

String input = "Cricket!"; String upper = input.toUpperCase(); //stores "CRICKET!" String lower = input.toLowerCase(); //stores "cricket!"  

This will clarify your doubt

like image 36
Crickey Avatar answered Oct 08 '22 18:10

Crickey