The toUpperCase
method doesn't change the value of the char
(it can't); it returns the uppercased char
. Change
Character.toUpperCase(c);
to
c = Character.toUpperCase(c);
UPDATE
The updated question now indicates that the uppercased characters are to be printed as they're typed. Java cannot do that, because Java doesn't control how the O/S echoes user input to the screen. My solution above would only produce additional output, even if it is uppercased.