Results 1 to 9 of 9
Thread: string-int-char
- 02-25-2012, 12:20 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 8
- Rep Power
- 0
- 02-25-2012, 01:14 PM #2
Member
- Join Date
- Oct 2011
- Posts
- 14
- Rep Power
- 0
Re: string-int-char
1. Parse each to an int
2. Cast them to char
Example:
Java Code:public class StringToChar { public static void main(String[] args) { String[] s = {"104", "105", "103"}; for(int i = 0; i < s.length; i++) { System.out.println((char)(Integer.parseInt(s[i]))); } } }
- 02-25-2012, 02:03 PM #3
Re: string-int-char
Cross posted at string-int-char
- 02-28-2012, 10:29 AM #4
Member
- Join Date
- Jan 2012
- Posts
- 8
- Rep Power
- 0
- 02-28-2012, 11:10 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,479
- Rep Power
- 16
Re: string-int-char
Um, then use the code supplied and modify it for your requirements (which did imply a String[]).
Or are you expecting someone to write this for you?Please do not ask for code as refusal often offends.
- 02-28-2012, 11:14 AM #6
Member
- Join Date
- Jan 2012
- Posts
- 8
- Rep Power
- 0
- 02-28-2012, 11:25 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,479
- Rep Power
- 16
Re: string-int-char
Then show us what you;ve tried and where it is going wrong.
Please do not ask for code as refusal often offends.
- 02-28-2012, 04:08 PM #8
Member
- Join Date
- Feb 2012
- Location
- Delhi, India
- Posts
- 5
- Rep Power
- 0
Re: string-int-char
give this complete step by step process a try..
1. first split that string using split() method of String class. splitting should be done using comma as separator(NEED TO B PAASED AS AN ARGUMENT TO split() method). this will return you a String Array.
2. But now u know, your first n last String in String Array has few unwanted part i.e. opening square bracket "[" in first string and closing square bracket "]" in last string. so remove these using subString method of string and save it at their location. Now u have your input String Array ready...
3.parse each to int
4. cast them to char (refer above posted code for step 3 n 4)
I can give u complete code, but i also want u to give it a try first.............. so that a day will come tomorrow, when u will be resolving my JAVA issuesssssss..ALL THE BEST :-)
- 02-29-2012, 11:18 AM #9
Member
- Join Date
- Jan 2012
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Help with char and string
By mehnihma in forum New To JavaReplies: 13Last Post: 11-01-2011, 11:06 PM -
check a string char by char
By Sotsiak in forum New To JavaReplies: 2Last Post: 10-23-2010, 09:24 PM -
Char to Bit String
By Krooger in forum New To JavaReplies: 2Last Post: 01-29-2010, 02:26 AM -
char to string
By kian_hong2000 in forum New To JavaReplies: 2Last Post: 08-25-2008, 01:51 PM -
Help with, String, Char
By lenny in forum New To JavaReplies: 1Last Post: 07-25-2007, 02:58 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks