• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Get Ascii value for a character

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just cast it to an int.
 
Dinesh Jayram
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
reply
    Bookmark Topic Watch Topic
  • New Topic