Results 1 to 3 of 3
Thread: char conversion to uppercase
- 10-12-2010, 02:45 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
char conversion to uppercase
Hello all I am new to java and am having a problem with a particular part of my code :
//Constructor
public CarRental (String initialCustomerName, String initialMake, char initialRatingKey) {
customerName=initialCustomerName;
make=initialMake;
ratingKey=initialRatingKey;
switch(initialRatingKey)
{
case 's': initialRatingKey=initialRatingKey.toUpperCase();
case 'c': initialRatingKey=initialRatingKey.toUpperCase();
case 'u': initialRatingKey=initialRatingKey.toUpperCase();
case 't': initialRatingKey=initialRatingKey.toUpperCase();
case 'b': initialRatingKey=initialRatingKey.toUpperCase();
}
}
What I am trying to do is to convert a char entry to uppercase if a lowercase letter is typed in. Apparently initialRatingKey.toUpperCase() is not legal. I would appreciate any help thanks!
-
Why do the to upper case in the Switch? Why not just call toUpperCase on all char input. If it already is upper case then no changes are made. Oh and toUpperCase is a static method of the Character class meaning it should be called on the Character class itself and it must take a parameter. Please look up the Character API for more details.
- 10-12-2010, 03:09 AM #3
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
replaceALL(char oldChar, char newChar) method
By arson09 in forum New To JavaReplies: 0Last Post: 04-28-2010, 06:48 AM -
uppercase and lowercase please help
By cuziwow in forum New To JavaReplies: 4Last Post: 04-11-2010, 08:54 AM -
Need Help for this problem Uppercase.
By ezered in forum New To JavaReplies: 5Last Post: 12-04-2009, 01:05 AM -
drawing char by char with Graphics
By diggitydoggz in forum New To JavaReplies: 5Last Post: 12-27-2008, 01:49 PM -
UpperCase problem
By logieen in forum New To JavaReplies: 1Last Post: 08-04-2008, 12:26 AM
Bookmarks