Hey there! any question in your mind? Ask It Now!.

Popular Categories

How to Change String to Lower Case or Upper case in Java?

+1 vote
asked in Programming by raman (530 points)
retagged by Bhartesh
I have a string which is very long containing Some paragraphs of a web page Now I want , every letter should be in lower case so that I can compare it, Please tell me conversion of upper case also.

1 Answer

+1 vote
answered by jatin Expert (3,823 points)
selected by raman
Best answer

Its very Simple lets say you have a String

strTest = Hello Test.

For Lower Case.

strTest = Hello Test.

strTest = strTest.toLowerCase();

Now strTest will be = hello test.

For Upper Case

strTest = Hello Test.

strTest = strTest.toUpperCase();

Now strTest will be = HELLO TEST.

I hope you got the Answer ,Enjoy!


commented by raman (530 points)
Thanks Dear it was so simple  :P
commented by krish Expert (6,310 points)
@Jatin I have a question what if I have to convert upper case to in this fromat in which first letter would be capital and others letter would be small?
commented by Himanshu Expert (5,940 points)
@Krish see this code here we are  Converting a string to in this form where first letter is capital and others are small, As you was asking.
String A = "ASDF";
      String B = A.substring(0, 1).toUpperCase() + A.substring(1).toLowerCase();

OUT PUT : Asdf

I hope this will help you out.

Related Questions

+3 votes
1 answer 912 views
–1 vote
0 answers 192 views
+6 votes
2 answers 3,554 views
+2 votes
1 answer 224 views
+2 votes
1 answer 1,289 views
+3 votes
1 answer 579 views
+8 votes
2 answers 222 views

Not a Member yet?

Ask to Folks Login

My Account
328 Folks are online
0 members and 328 guest online
Your feedback is highly appreciated