• Post Reply Bookmark Topic Watch Topic
  • New Topic

What am I doing wrong? toUppercase()  RSS feed

 
M Newmark
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am learning about strings right now, and this part of my assignment is giving me trouble. Im trying to captialize only the first letter that I'm pulling from the array using the get method.

I keep getting "cannot find symbol" for toUpperCase for the following:

Obviously more in the method, just posted that part that I cant figure out. What am I doing wrong here?

[moderation comment] added code tags, fixed indentation.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

You didn't show us where word gets declared.

Also, in future posts please UseCodeTags when posting code. Thanks.
 
M Newmark
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Welcome to the Ranch.

You didn't show us where word gets declared.

Also, in future posts please UseCodeTags when posting code. Thanks.


Thanks, and will do..
 
Les Morgan
Rancher
Posts: 768
19
C++ Java MySQL Database Netbeans IDE Oracle Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look in your class Word, it is not a String. See if there is anything there that will give you a String to use.
M Newmark wrote:
Bear Bibeault wrote:Welcome to the Ranch.

You didn't show us where word gets declared.

Also, in future posts please UseCodeTags when posting code. Thanks.


Thanks, and will do..
 
Campbell Ritchie
Marshal
Posts: 55772
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless Word#getNoun returns a String, you will be in the realms of StringBuilder#append(Object) which calls the toString method or adds “null” for a null.
What does your Word class represent? Is it a word, or a phrase?

Can you put all the words into your StringBuilder as they are, then iterate the StringBuilder looking for spaces, and capitalise the first char following. The Character class probably has a method to convert to upper case. Beware of ß in German which turns into two letters in upper case: SS.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!