Suppose I have a string of 123456789. I would like to split this string and each number goes in a different slot in the array. I can’t use the split() method because there is nothing to split on. How would I accomplish this in Java.
Suppose I have a string of 123456789 . I would like to split this
Share
And after this you
intarraywill be array of your numbers.If your integer can be negative too, you must take it’s absolute value and make same operations, and after that multiple first array value by
-1. But I guess, it’s not needed.EDIT:
I think, I don’t understand your question properly. If you want to split only string, you must use this lines only. I wrote about integers,which might be helpful too.