首頁  >  問答  >  主體

java的基本数据类型的包装类是引用类型吗?

巴扎黑巴扎黑2716 天前567

全部回覆(2)我來回復

  • 怪我咯

    怪我咯2017-04-18 10:39:36

    引用JVM規範中的一段,詳情請參閱

    For every parameter declared in a method declaration, a new parameter variable is created each time that method is invoked. The new variable is initialized with the corresponding is invoked. The new variable is initialized with the corresponding argument value the mod.

    規範中說每次方法調用,方法中的參數都會初始化。

    上面

    的指向並沒有改變。

    回覆
    0
  • PHP中文网

    PHP中文网2017-04-18 10:39:36

    java 中方法用到的都是值傳遞,即使是引用,傳遞的也是原來引用的拷貝值

    方法只能讓參數引用中的屬性改變,而不能改變參數的參考位址

    而且你可以看Integer的源碼:

    它包裝的值value是被final修飾的,也就是只能被賦值一次,賦值後值不再改變。

    另外你可以試試看別的引用類型,看看能不能被改變,例如String

    回覆
    0
  • 取消回覆