how to implement C# ref in Java

In C# we have ref and out, while in Java we don't.

 

To do something similar to ref, there are normally 4 ways.

Check this out: http://stackoverflow.com/questions/5614562/how-to-do-the-equivalent-of-pass-by-reference-for-primitives-in-java

Choice 1: make a public member variable in a class

Choice 2: return the value instead of pass by reference

Choice 3: make it a class or static variable

Choice 4: Create a single element array of type int and pass that

 

posted @ 2015-01-02 01:21  新一代的天皇巨星  阅读(204)  评论(0)    收藏  举报