This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Folks, i've typed in another program from Ivor Horton's most excellent "Beginning Java 2", and have a query regarding it. The program is about counting the number of whitespaces, vowels, and consonants in a string variable. OK, no problem there. The code is listed below.
I sort of understand the code, apart form the line:- char ch = Character.toLowerCase(text.charAt(i));
What's going on here? So we've defined a variable ch, of type ch. But then what? I can't figure out what we're doing with it. Any help would be greatly appreciated. Cheers
John Bonham was stronger, but Keith Moon was faster.
Hi Steve, It takes the i-th character of text, and converts it to lowercase. The text.charAt(i) is the i-th character of the String text. toLowerCase() is a static method of the Character wrapper class. He changes the character ch to lowercase so that 'A' and 'a' can be compared in one single expression: ch == 'a' rather than with ( ch == 'a' ) || ( ch == 'A' ) [ February 01, 2003: Message edited by: Barry Gaunt ]