|
-
Oct 3rd, 2007, 05:57 AM
#1
Thread Starter
Addicted Member
Convert String to char or check if String contains only numbers
Hello,
I have been given a programming assignment, which i believe is not properly thought through.
In a string i have some numbers:
String cpr = "1234"
Now, i must test the this string contains only numbers. It is suggested that i use Character.isDigit() to check it, but then i would need to convert the string to an char - and i havent found any easy ways of doing this. Are there any other methods of testing if a string consists of only numbers??
I was also told to implement a toString method which is never used. Now, what i think is that, cpr should be a Character, and then i would use toString to convert it to string when needed, but.....not according to the teacher
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|