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

Posted by devoured elysium on Stack Overflow See other posts from Stack Overflow or by devoured elysium
Published on 2010-05-10T21:21:15Z Indexed on 2010/05/10 21:34 UTC
Read the original article Hit count: 230

Filed under:
|

Something like the following:

ref example:

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

void main() {
    String abc = "abc";
    changeString(ref abc);
    System.out.println(abc); //prints "def"
}

out example:

void setString(out String str) {
    str = "def";
}

void main() {
    String abc;
    changeString(out abc);
    System.out.println(abc); //prints "def"
}

© Stack Overflow or respective owner

Related posts about java

Related posts about c#