• Post Reply 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Compile error message

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks.
 
Ranch Hand
Posts: 280
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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?

-Amit
 
Jeff Bosch
Ranch Hand
Posts: 805
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created the following test program from your code, and it worked fine:



Could you have a typo in your source?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!