Ok guys, I need help, I found a couple of examples but don't understand. None of the Java examples uses this method for Converting letters uppercase to lowercase:

int offset = (int) 'a' -(int) 'A';
char lowercase = (char)((int)uppercase + offset);

Can somebody get me on the right track here because I'm stuck after public static void main(String [] args). I just need somebody to get me on the right track. Thanks. Seems like this was the only thing that wasn't explained at all in the Java textbook and the Java for dummies series.

Recommended Answers

All 3 Replies

Well, unless you are doing it for some algorithm assignment, then just use String toLowerCase()

Hmm ok, but another question, how would I do a single line for assigning all the letters A throw Z instead of making a command with 26 different lines of codes, in other words, shorting it up?

// to convert an entire string
String lowercaseString = originalString.toLowerCase();

You don't need 26 lines. You just call the toLowerCase() function on the string itself. That string can be a single letter or many letters.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.