Hi, how can I convert numbers into words without using arrays? or is it possible not to use arrays?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi, how can I convert numbers into words without using arrays? or is it possible not to use arrays?
i think you should really use a list..
or check the API if theres any method that converts a number into a String/word
Integer.toString() converts an int to a string....after which you can stitch the strings together.
Last edited by copeg; December 30th, 2009 at 10:30 PM.
So, if I want to do the opposite, does String.toInteger () work?
Regards,
Shaun.
Integer.parseInt() is what you are looking for. If you are unsure that the String is an integer, be sure to validate it before, or catch any NumberFormatExceptions that could be thrown
see: how to convert string to int
hhaha i thought he was asking how to convert a number into a words LITERALLY
like 1 - one..! 1000 - one thousand.... deym...!
lol, no. I need to get the value of a string. In Olde BASIC (Sinclair, Commodore etc...) you would use something like VAL or VAL$. Ie, LET A=VAL "100" or LET B=VAL B$ would give you 100 or the literal value of B$ as long as B$ only contains numbers and not letters or other characters.
Regards,
Shaun.