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

后端 未结 7 1482
陌清茗
陌清茗 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<String> doThings() {
      //
    }
    
    void doThings(ArrayList<String> list) {
      //
    }
    
    Pair<String, String> doThings() {
      //
    }
    

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

    0 讨论(0)
提交回复
热议问题