File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Compile error message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile error message" Watch "Compile error message" New topic

Compile error message

Becky Wilson

Joined: Oct 21, 2004
Posts: 1
I need help with a compiler message:
int cannot be dereferenced. Can anyone help with this?
Here is the code it is references:

decrypted = (index.charAt(0) - 7) + (index.charAt(1) - 7) + (index.charAt(2) - 7) + " " + (index.charAt(4) + 3) + (index.charAt(5)+ 3) + " " + (index.charAt(6) + 3) + (index.charAt(7) + 3) + (index.charAt(8) + 3) + (index.charAt(9) + 3);
//this is the calculation to decrypt the input and names it decrypted

Here is the actual compiler message:
int cannot be dereferenced

decrypted = (index.charAt(0) - 7) + (index.charAt(1) - 7) + (index.charAt(2) - 7) + " " + (index.charAt(4) + 3) + (index.charAt(5)+ 3)

the pointer is aimed at the . between the word index and charAt
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Hi, Becky -

It's possible the error occurred on the line before the snippet, or that decrypted is an int (though that should give a different error). Can you provide the declaration for decrypted and index? Maybe I can help if I see more.


Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Amit Saini
Ranch Hand

Joined: Oct 20, 2004
Posts: 280
You generally get this error if you are using the .operator on a primitive.
eg int i; i.(any function) will give you this error. Which is why you need to use wraper classes to perform those operations.

Whats the datatype of index?

Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
I created the following test program from your code, and it worked fine:

Could you have a typo in your source?
I agree. Here's the link:
subject: Compile error message
It's not a secret anymore!