Results 1 to 3 of 3
  1. #1
    PsychoNaut is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default 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!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    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.

  3. #3
    PsychoNaut is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

Similar Threads

  1. replaceALL(char oldChar, char newChar) method
    By arson09 in forum New To Java
    Replies: 0
    Last Post: 04-28-2010, 06:48 AM
  2. uppercase and lowercase please help
    By cuziwow in forum New To Java
    Replies: 4
    Last Post: 04-11-2010, 08:54 AM
  3. Need Help for this problem Uppercase.
    By ezered in forum New To Java
    Replies: 5
    Last Post: 12-04-2009, 01:05 AM
  4. drawing char by char with Graphics
    By diggitydoggz in forum New To Java
    Replies: 5
    Last Post: 12-27-2008, 01:49 PM
  5. UpperCase problem
    By logieen in forum New To Java
    Replies: 1
    Last Post: 08-04-2008, 12:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •