File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes can't be dereferenced... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

can't be dereferenced...

Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22

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

Joined: Mar 16, 2001
Posts: 986

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?


Please ignore post, I have no idea what I am talking about.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30506
    
150

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.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
Thanks for all the help. I'm too stupid to realize the obvious. Thanks again.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9046
    
  10
Please add further responses to this duplicate thread.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't be dereferenced...