Java for loop by value or by reference

前端 未结 6 812
忘了有多久
忘了有多久 2020-12-10 04:37

I figured out a a problem in my Code. First the code:

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
           


        
6条回答
  •  心在旅途
    2020-12-10 05:21

    The for-each loop don't modify the objects contained in the Collection of objects it's iterating over. It's passing the value not the reference.

提交回复
热议问题