Does array changes in method?

前端 未结 6 844
一生所求
一生所求 2020-12-10 02:36

When I write like this:

public class test {

    void mainx()
    {
        int fyeah[] = {2, 3, 4};
        smth(fyeah);
        System.out.println(\"x\"+fy         


        
6条回答
  •  -上瘾入骨i
    2020-12-10 02:53

    The int is a value type so 5 is passed directly into smth which can only modify the local copy. An array on the other hand is a reference type so the elements of that array can be modified.

提交回复
热议问题