This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
hi Jackie, you can use NumberFormatter for the purpose. here is a link for SUN's tutorial about it. also here is a sample code i tried with it,
the output was, Output:8,000,000,000 the only problem i found was- format() method doesn't accept long as simple argument even if we cast 8000000000 to long explicitly, it expects integer argument instead so i had to use double to specify that big value.. hope this helps. regards maulin
Joined: Apr 18, 2002
Maulin, thanks so much for the prompt reply. However, I would like the number to be 8, 000, 000, 000 (with space) Also, for a string: "testingmessingtestingmessageasdasdasasdasasd" how can i arbitrary break the string into 10 character with a space in between? Thanks!
Joined: Nov 04, 2001
hi Jackie, say you want to put a space at character position 'pos' and you have the string 'str' then you can write the following to achieve that, str = "8000000000"; char space = ' '; str = new StringBuffer(str).insert(pos,space).toString(); please let me know if this works. ive not tried this code... regards maulin