• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

&simi

 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I was studying for the exam, I came across a sample question that wanted to know if the following code would compile:
int i = &simi;
According to the test the answer to the question is true, but I just wanted to know what &simi is and why it is true.
Thanks,
Brian
 
Ranch Hand
Posts: 371
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
According to RHE, the only character that may begin an identifier is $, _, and both upper and lower case letters. I suspect the question was testing you on the difference between C++ and Java. In C++, &someIdentifier is the numerical address of the variable someIdentifier and is also an int. But Java does not support manipulations of pointers, and & has no special meaning in Java. So, it should not compile.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
may I add something to this ?
I came across the same question and I, first, did not really understand the idea behind it. But if you look carefully at the comment in the answer, it "says" that the "&simi;" is in fact supposed to be a ~i; which is the bitwise inversion operator.
I think the author of that test mistyped the question and did not have in mind to make the difference between C/C++ and Java clear.
To resume, I think that &simi; should in fact be ∼i which is a way to encode the ~ character independently of the program that reads the file...
Does this make sense ?
Hope it help
 
reply
    Bookmark Topic Watch Topic
  • New Topic