• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

how does "toLowerCase" work?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try it with "KiSS".
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 27368
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic