Link to home
Start Free TrialLog in
Avatar of zathael
zathael

asked on

char and int conversions...

I need to do the following:

I have an integer with a value, and for this example we'll use 65.

Now, I want to convert that value to the character 65 or "A".

In C, I can use:
   int temp1=65;
   char temp2;

   temp2=temp1;

and boom, I have temp2 == 'A'

However, in Java I can't do that.  I can do:
  int temp1;
  char temp2='A';
 
  temp1=temp2;

and instantly temp1=65, but I can't go the other way.  Is there a way to do this?

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of webster030697
webster030697

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zathael
zathael

ASKER

The reason I needed to do this is there are certain c routines that I'm taking to Java, certain functions that I find useful in my projects that work great in C, and now I need in Java.  One such function required this.  For the most part I can work around them, but rather than add 10 lines of code to do the same thing, I thought there might be a better way to take it to one line of code. Thank you for your answer.