Discussions
Categories
Groups
Advertisement
Child Item
Home
Topics
Technology & Internet
Software & Web Development
Development
casting char[] to int in java
jackofnotrades
say I have some stuff in a char array data[] and data
= 7. I want to add data
to an int or change data
into an int so I can add it, but I keep getting the ASCII table value 55.
I've tried int x = (int)data
but that didn't work. This is bugging me now because I'm sure its something simple I've just become confused looking at all the int to char tutorials but can't seem to find a char[] to int one. Anyone got any ideas or pointers ?
Find more posts tagged with
Quick Links
All Categories
Recent Posts
Activity
Unanswered
Groups
Best Of
Advertisement
Advertisement
Comments
jackofnotrades
Got it ... had to make it into a string first, If anyone has an easier way I wouldn't mind seeing it !
String strChar2Int = String.valueOf(data
);
x = Integer.parseInt(strChar2Int);
Webmonkey
Don't know if this works but have you tried
stringByte = String.valueOf(data[i]); int x = Integer.parseInt(stringByte);
Edit:
Ok you just got there before me!