码迷,mamicode.com
首页 > 编程语言 > 详细

how to implement C# ref in Java

时间:2015-01-02 06:21:49      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

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

 

how to implement C# ref in Java

标签:

原文地址:http://www.cnblogs.com/neweracoding/p/4198059.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!