I want to decompose a String array into Long array or List.
I don’t want to use Loop.
Is there any Java Method to do this.
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.
There is no O(1) operation to “convert” a
String[](with numeric strings) to along[]. It will always be O(n), if the loop visible or hidden in some thirdparty method.If you don’t want to “see” the loop, simply implement a method
and implement
We can do it recursively too – it is still O(n), less performant and doesn’t look like a loop:
Note – because I start getting downvotes for the recursion example: It is purely academic and not inteded for use in production code – thought, that was clear 😉