Java for loop by value or by reference

前端 未结 6 816
忘了有多久
忘了有多久 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:20

     s = "over"; 
    

    just changes the reference of s and not the String in the array.

    blablubb[i] = "over";
    

    changes the value stored at ith location in the array

提交回复
热议问题