Does Java have something like C#'s ref and out keywords?

后端 未结 7 1525
陌清茗
陌清茗 2020-11-27 03:31

Something like the following:

ref example:

void changeString(ref String str) {
    str = \"def\";
}

void main() {
    String abc = \"abc\";
    chan         


        
7条回答
  •  野性不改
    2020-11-27 04:07

    Three solutions not officially, explicitly mentioned:

    ArrayList doThings() {
      //
    }
    
    void doThings(ArrayList list) {
      //
    }
    
    Pair doThings() {
      //
    }
    

    For Pair, I would recommend: https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/tuple/Pair.html

提交回复
热议问题