You'll need to provide a little context. Are you talking about in a GUI, when a key is pressed? Or just some character that comes from wherever? Or something else?
And do you care about the key, or about the character? They're two different things.
Paul Clapham wrote:So probably you want the Unicode code point for the character, not its keyboard code. You get that simply by casting the char to an int, like so:
But the point is that I'm receiving wrong values (I mean different than those provided by my teacher)
My previous lesson was about "encryption", and after every lesson he is giving me different task, like write program in my language (which is going to be used during my school secondary school certificate - IT)
For example for 'A' im receiving 65, and my teacher said its $41 (this dollar doesn't really matter, I need just number for calculations)
$ is the Visual Basic (ugh) HEX symbol, and it's probably used in other languages as well. Apparently your teacher has a history in one of these languages before he started Java. Tell him that Java uses 0x instead and that he should consider switching to prevent confusion; you may even get a little extra credit for it.