Cannot find symbol - method: toUppercase(char)?

2.8k views Asked by At

I'm working on a Pig Latin method and now I'm trying to do the if-else statement: if Start word is capitalized, lowercase Start and uppercase End. This is so if a word is at the beginning of a sentence or is just capitalized in general (Ex. John), the Pig Latin will capitalize the first letter when translating (Ex. Ohnjay). I cannot figure out why my code won't work, maybe I'm not storing values correctly... I admit straight out>> this is for a homework assignment, if you don't like, don't answer<< Thanks for any help!

            else if (vowel > 0)
            {
                Start = Input.substring(0, vowel);
                End = Input.substring(vowel);
                char StartFirstLetter = Start.charAt(0);
                char EndFirstLetter = End.charAt(0);

                if (Character.isUpperCase(StartFirstLetter) == true)
                {
                    End = Character.toUppercase(EndFirstLetter);
                }
                else
                {
                Result = End + Start +"ay ";
                }

here's the error:

                StringUtil.java:175: error: cannot find symbol
                    End = Character.toUppercase(EndFirstLetter);
                                   ^
                  symbol:   method toUppercase(char)
                  location: class Character
                1 error
3

There are 3 answers

0
rgettman On

Ironically, the c needs to be in uppercase for the toUpperCase method:

Character.toUpperCase(EndFirstLetter);
0
holtc On

The error means that the method cannot be found, meaning that you have misspelled the method you are trying to call, which is:

Character.toUpperCase(EndFirstLetter)

as rgettman has pointed out. It is useful to try and understand the error messages, as you can learn quite a bit from them.

0
Dyrandz Famador On

Try this:

Character.toUpperCase(EndFirstLetter);