Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

can't be dereferenced...

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 1067
2
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for all the help. I'm too stupid to realize the obvious. Thanks again.
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please add further responses to this duplicate thread.
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic