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
816 views
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.
Thanks! 

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();
      System.out.println(B);

OUT PUT : Asdf

I hope this will help you out.

Related Questions

+3 votes
1 answer 719 views
+2 votes
2 answers 796 views
–1 vote
0 answers 126 views
+6 votes
2 answers 2,574 views
0 votes
1 answer 160 views
+4 votes
5 answers 732 views
+2 votes
1 answer 153 views
+2 votes
1 answer 607 views
+3 votes
1 answer 382 views
+8 votes
2 answers 125 views

Not a Member yet?

Ask to Folks Login

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