| Author |
splitting String into substrings
|
ramakrishna ranga
Greenhorn
Joined: Sep 22, 2007
Posts: 3
|
|
String s = "6158"; i have to split this as substrings like 6, 1, 5, 8, 61, 15, 58, 615, 158, and 6158. Here is my code code: -------------------------------------------------------------------------------- String s = "6158"; for(int i=0;i<s.length();i++) { System.out.println(s.charAt(i)); } int i=0; int l=1; while(i<s.length()){ while(l<=s.length()){ System.out.println(s.substring(i,l)); l++; } i++; } -------------------------------------------------------------------------------- Output: 2 3 1 9 2 23 231 2319 But i am not able to get the all the values, i have tried lot of ways. please any one help me how to get it.
|
 |
Freddy Wong
Ranch Hand
Joined: Sep 11, 2006
Posts: 959
|
|
|
|
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
|
 |
 |
|
|
subject: splitting String into substrings
|
|
|