Does Java 5 or higher apply some of form of “boxing” to arrays? This question came to mind as the following code goes through an array as if it’s an Iterable.
for( String : args ){
// Do stuff
}
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.
No, arrays are always reference types. There’s no need for boxing or unboxing, unless it’s on the access for each element. For example:
Also note that although the enhanced for loop is available for both arrays and iterables, it’s compiled differently for each.
See section 14.14.2 of the JLS for the two different translations of the enhanced for loop.