• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

QUICK Java Questions

Mods: I want to solve it now if possible...

First, I checked the Java API and didn't see anything on what I'm looking for, maybe I'm looking in the wrong spots

How do I make a char lower case? Like 'A' to 'a'

toLowerCase() doesn't work because it's meant for strings, I guess I could make the char a string and then make it lower case and back to a char, but is there a better way?
 
If your using java, I'm assuming speed is not really a main concern. So just do the char->string->char conversion.

<--- lazy guy
 
Originally posted by: clamum
Put the primative char into a Character wrapper class and use the toLowerCase() method.
Character.toLowerCase() is static so instantiation is completely unnecessary.
 
Solution 1:

char k;
k = new Character(k).toLowerCase();


Solution 2::

char k;
if (k >= 'A' &amp;&amp; k <= 'Z')
k += 'a' - 'A';



Solution 3:
char k;
String temp = new String(k);
temp = temp.toLowerCase();
k = temp.characterAt(0);
 
Originally posted by: AgaBooga
I have no clue what a character wrapper class is, any simpler way?

A Character wrapper class puts the primative type char into a object and then you can call its methods.

Character theChar = new Character('A');
lowerCaseChar = theChar.toLowerCase();

That puts the capital letter 'A' into the wrapper and then calls the toLowerCase() method which returns a lower case version char (standard primative type).

Probably an easier way to do it though.

EDIT: Ah, did not know that Manly. Thanks for the tip.
 
Back
Top