Results 1 to 4 of 4
Thread: digit spacing
- 06-09-2009, 12:34 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 16
- Rep Power
- 0
[Solved]digit spacing
Hi, im writing an application that collects a number consisting of 5 digits,for example, 11234 from the user. The problem i have is that i want to separate the individual digits and display them separated by 3 spaces. thank you in advance for your help.
Last edited by puk284; 06-09-2009 at 12:47 PM.
- 06-09-2009, 01:10 AM #2
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
If you want 3 spaces between each digit, try something like this.
If you don't want spaces on the ends, just trim the string.Java Code:public String getSeparatedString(String separ){ String spacing = " "//three spaces String ret = spacing; for(char c : separ.toCharArray()){ ret += c + spacing; } return ret; }If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
-
More information may help get a better answer. For instance, how are you getting the numbers and how are you displaying them? Is this a console application, or is this a Swing or other GUI? What have you tried so far, and can you show us the code?
Best of luck.
- 06-09-2009, 02:49 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Similar Threads
-
Locating a digit within a string
By ScentOfAWookie in forum New To JavaReplies: 8Last Post: 03-27-2009, 05:23 PM -
Problem with margins/spacing
By joseche in forum AWT / SwingReplies: 2Last Post: 12-26-2008, 08:22 PM -
Spacing buttons on a panel
By 2o2 in forum New To JavaReplies: 8Last Post: 10-20-2008, 10:44 AM -
Java newb Q: 8-digit id
By 1111FM in forum New To JavaReplies: 2Last Post: 09-29-2008, 02:37 PM -
Help with spacing in java
By barney in forum New To JavaReplies: 1Last Post: 07-31-2007, 08:03 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks