Results 1 to 6 of 6
- 07-30-2007, 02:11 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 41
- Rep Power
- 0
- 07-30-2007, 05:31 PM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
Integer.parseInt() takes a String and turns it into a number.
To get each character use the String.toCharArray();
For example you can do the following:
BTW the n+"" is a shortcut to turn n into a String.Java Code:String num = "12345"; char[] arr = num.toCharArray(); for (char n : arr) { int i = Integer.parseInt(n + ""); print(i); }
- 08-01-2007, 05:07 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 41
- Rep Power
- 0
very well
thanks I know that was a silly question
sorry
- 08-02-2007, 04:46 AM #4
Senior Member
- Join Date
- Jul 2007
- Posts
- 130
- Rep Power
- 0
One of our friend have made this simple explanation bout Strings in Java if u need some added reference besides the one from sun, here's the link
http://www.java-forums.org/java-book...va-string.html
- 08-02-2009, 03:21 PM #5
Member
- Join Date
- Aug 2009
- Posts
- 1
- Rep Power
- 0
Hey i have a question
Authentication A1 = new Authentication(1);
System.out.println("Enter ID");
A1.SetID(Integer.parseInt(System.in.read()));
System.out.println(A1.GetID());
Authentication is the name of Class i made
Problem is when i dont use Interger.parseInt if i enter value 1 it prints it 50
and if i convert that to int it gives me error :S
- 08-02-2009, 03:46 PM #6
Member
- Join Date
- Aug 2009
- Posts
- 21
- Rep Power
- 0
Similar Threads
-
How to convert a string into a BigInteger
By valery in forum New To JavaReplies: 4Last Post: 09-13-2011, 01:32 PM -
How to convert integer to the hexadecimal and octal number
By Java Tip in forum java.langReplies: 0Last Post: 04-06-2008, 07:40 PM -
Validate/Convert a number using the current Locale()
By Java Tip in forum Java TipReplies: 0Last Post: 03-01-2008, 10:01 PM -
convert string to float
By miss_dot in forum NetBeansReplies: 1Last Post: 11-14-2007, 11:26 PM -
Help with convert a double type number
By trill in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks