DZone ForumsDZone Forums  

Go Back   DZone Forums > Community > Languages & Frameworks > Java
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
LinkBack Thread Tools Display Modes

Topic: Separate a five digit number into parts.
Old 06-25-2008, 01:53 PM   #1 (permalink)
Member
 
Join Date: Feb 2008
Posts: 1
Suppose i have a five digit number. How can i convert this number so that this number is divided into five parts and then separated by three blank spaces.
Suppose i have a number 12345 then i want output like that 1 2 3 4 5
junaidjee is offline   Reply /w Quote -


Old 07-11-2008, 06:40 AM   #2 (permalink)
Member
 
Join Date: Jun 2008
Posts: 6
Is this kind of a solution u are expecting ???

public static void main( String[] args )
{
String s = "12345";
String result = "";

for ( int i = 0; i < s.length(); i++ )
{
if ( result.length() > 0 )
{
result += " ";
}
result += ( s.charAt( i ) );

}
System.out.println( "Result is =>>> " + result );
}
diasmvds is offline   Reply /w Quote -


Thread Tools
Display Modes



All times are GMT -5. The time now is 09:24 PM.