This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how does Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "how does "toLowerCase" work?" Watch "how does "toLowerCase" work?" New topic
Author

how does "toLowerCase" work?

nick magic
Greenhorn

Joined: Mar 03, 2006
Posts: 11
public class Book
{
public String title="kiss";
public String getTitle(){
return title;
}
public static void main(String[] args)
{
Book b=new Book();
String s=b.getTitle();
String t=s.toLowerCase();
System.out.println("the title is"+t);
}
}
the code prints the title is kiss.
i wonder what does toLowerCase mean
thanks!


la qualite de la vie!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Try it with "KiSS".


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
mohit junejaa
Ranch Hand

Joined: Feb 24, 2006
Posts: 41
if the string object on which toLowerCase() is invoked contains uppercase characters , then a new string object with all characters lowercase is returned

however if the string does not contain lowercase characters then original string object is returned


scjp 1.4
Kj Reddy
Ranch Hand

Joined: Sep 20, 2003
Posts: 1697
It converts all entire string into lowecase string.
Try to changing the following line:
public String title="kiss";

to

public String title="KiSs";

and run the program then you will know the difference.
Pran Pal
Greenhorn

Joined: Mar 02, 2006
Posts: 10
Next time, type this in google: "java api toLowerCase()". It's going to give you the link to sun's api, which contains all the methods with the description.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35439
    
    9
The javadocs only tell you what the method does, they rarely talk about how something happens. But the method is written in Java, and part of the class library source (which ships with the JDK), so you can look it up there.

And if you're really interested in how toLowerCase works, check out Peter Norvigs take on it, and study his faster method.


Android appsImageJ pluginsJava web charts
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16487
    
    2

It's interesting that Norvig picked toLowerCase rather than toUpperCase; his sped-up version cannot be used for toUpperCase because the upper-case version of the ß character is "SS", making the resulting string longer than the source string.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: how does "toLowerCase" work?
 
Similar Threads
output for this program
Object Reference Not Initialized
String literals
sorting by a primitive int field
compareTo