e.g.:
- If the number is 234, I would like the result to be
List<String>containing2,3,4(3 elements) - If the number is 8763, I would like the result to be
List<String>containing8,7,6,3(4 elements)
Does commons-math already have such a function?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
123becomes"123"). UseInteger.toString."123"becomes{'1', '2', '3'}). UseString.toCharArray.Vector<String>(or some other List type).{'1', '2', '3'}becomes a Vector with"1","2"and"3"). Use a for loop,Character.toStringandList.add.Edit: You can’t use the Vector constructor; have to do it manually.
There isn’t an easier way to do this because it really isn’t a very obvious or common thing to want to do. For one thing, why do you need a List of Strings? Can you just have a list of Characters? That would eliminate step 3. Secondly, does it have to be a List or can it just be an array? That would eliminate step 4.