Converting a lowercase char in a char array to an uppercase char (java) -
hello trying write little segment of code checks if each char
in char
array lower case or uppercase. right uses char's ascii number check. after checks should convert char upper case if not so:
for (int counter = 0; counter < charmessage.length; counter++) { if (91 - charmessage[counter] <= 0 && 160 - charmessage[counter] != 0) { charmessage[counter] = charmessage[counter].touppercase(); } }
charmessage
initialized in program. 160 part make sure doesn't convert space uppercase. how .touppercase
method work?
i way. first check if character letter , if lowercase. after use character.touppercase(char ch)
if(character.isletter(charmessage[counter]) && character.islowercase(charmessage[counter])){ charmessage[counter] = character.touppercase(charmessage[counter]); }
Comments
Post a Comment