Is there a method that will copy a section of an array(not arraylist) and make a new array from it?
Example:
[1,2,3,4,5]
and you create a new array from it:
[1,2,3]
Are there any one line/methods that will 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.
Here’s a java 1.4 compatible 1.5-liner:
You could do this in one line, but you wouldn’t have a reference to the result.
To make a one-liner, you could refactor this into a method:
then call like this: