How to create IN OUT or OUT parameters in Java

前端 未结 3 510
[愿得一人]
[愿得一人] 2021-01-17 18:05

In PL/SQL (or many other languages), I can have IN OUT or OUT parameters, which are returned from a procedure. How can I achieve a similar thing in Java?

I know this

3条回答
  •  自闭症患者
    2021-01-17 18:57

    There's no direct way. Other technique include:

    • Passing a holder object (a bit like your 1-ary array)
    • Using, e.g., an AtomicInteger
    • Passing a more useful object from a business perspective that happens to be mutable
    • A callback to a custom interface for receiving the result

    If you think about it, the array trick is not dissimilar to passing a T* in C/C++

提交回复
热议问题