Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Get Ascii value for a character

 
Dinesh Jayram
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is way to get Ascii value for a character

Suppose if the input value is A,
then output should be 65(the ascii value of A).

How to implement this in java?

your suggesions

 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just cast it to an int.
 
Dinesh Jayram
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyother way to implement this Ascii value.


 
Dinesh Jayram
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having problem with your code Maneesh Godbole

check it out

char c = 'A';
char c1 = '*';

System.out.println((int)c);
System.out.println((int)c1);

gives same output 65
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Works fine for me.
'A' gives 65 and '*' gives 42

Post your real code. There might be a typo or something there.
 
Maneesh Godbole
Saloon Keeper
Posts: 11027
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dinesh Jayram wrote:Is there anyother way to implement this Ascii value.


What's wrong with this way? Why is it unsuitable?
 
Dinesh Jayram
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently i am working with evaluation of math expressions, which
is in string format. I tried JEP, but not able to find out.

Thats what i queried here.

 
fred rosenberger
lowercase baba
Bartender
Posts: 12125
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you tell us exactly what you want to do, what you have, and what limitations there are. I still don't understand exactly what you are doing, or where you need help - and I'm probably not the only one.

folks are delighted to help, but you have to make it easy for them. so far, this thread has progressed like this:

1) you asked a question
2) you were given a valid way to do it
3) you said "I need another way"
4) you were asked why that way wouldn't work
5) you said "I'm trying to do something else entirely than what I originally asked"

at least, that's how it reads to me. Many folks here at this point are going to give up on reading this thread because it's too much work, and too much effort has been wasted.

The best way to get help is to clearly explain what you are doing, and where you are stuck. From you last post, I gather you are trying to parse a string that contains a mathematical expression. Is that correct? and if so, what EXACTLY is the issue you are having - tokenizing it, evaluating it, reading the string in from some input source, or something else?

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic