0

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
Erwin Bolwidt
  • 29,014
  • 15
  • 50
  • 74
Sen Park
  • 11
  • 1
  • 2
    If you get errors like `cannot find symbol`, then always read the [JavaDoc](https://docs.oracle.com/javase/7/docs/api/index.html?java/lang/Character.html) of the used class first. This is much faster and easier, than creating a question on Stackoverflow. – Tom Nov 22 '14 at 00:50

3 Answers3

3

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

Character.toUpperCase(EndFirstLetter);
rgettman
  • 172,063
  • 28
  • 262
  • 343
0

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.

holtc
  • 1,740
  • 3
  • 12
  • 34
0

Try this:

Character.toUpperCase(EndFirstLetter);
AstroCB
  • 12,101
  • 20
  • 56
  • 70
Dyrandz Famador
  • 4,439
  • 5
  • 23
  • 39