This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Get Ascii value for a character Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Get Ascii value for a character" Watch "Get Ascii value for a character" New topic
Author

Get Ascii value for a character

Dinesh Jayram
Greenhorn

Joined: Nov 26, 2008
Posts: 23
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

Joined: Jul 26, 2007
Posts: 10270
    
    8

Just cast it to an int.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Dinesh Jayram
Greenhorn

Joined: Nov 26, 2008
Posts: 23
Is there anyother way to implement this Ascii value.


Dinesh Jayram
Greenhorn

Joined: Nov 26, 2008
Posts: 23
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

Joined: Jul 26, 2007
Posts: 10270
    
    8

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

Joined: Jul 26, 2007
Posts: 10270
    
    8

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

Joined: Nov 26, 2008
Posts: 23
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

Joined: Oct 02, 2003
Posts: 11256
    
  16

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?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get Ascii value for a character