Bookmark Topic Watch Topic
  • New Topic

can't be dereferenced...

 
Robbie Harjes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Report post to moderator

This is obviously inside a for loop, i++ until there's no more characters left to process. For some reason I'm getting the "char cannot be dereferenced" error. I don't know how to fix this seeing how I'm using a .replace() function.. Not like I can just go something like "TEMP = Character.toUpperCase(TEMP);"
Help?
 
William Barnes
Ranch Hand
Posts: 986
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
  • Report post to moderator
The class "char" has a "replace" method?
So if you are in a loop the first interation would set TEMP to "h". And you want to than replace "h" with the result of a call to "replace" on the same variable. If there is a "replace" method, than why would you need to do the assignment?
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34686
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Report post to moderator
Robbie,
TEMP is called a primitive variable. Primative types include char, int and boolean. These types cannot be used to call methods. This is why you are getting the de-reference error.
 
Robbie Harjes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for all the help. I'm too stupid to realize the obvious. Thanks again.
 
Marilyn de Queiroz
Sheriff
Posts: 9065
12
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please add further responses to this duplicate thread.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic