且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从 Java 中的函数返回多个值

更新时间:2023-08-22 21:31:46

创建一个包含您需要的多个值的类.在您的方法中,返回一个作为该类实例的对象.瞧!

Create a class that holds multiple values you need. In your method, return an object that's an instance of that class. Voila!

这样,您仍然返回 一个 对象.在 Java 中,您不能返回超过 一个 的对象,无论它是什么.

This way, you still return one object. In Java, you cannot return more than one object, whatever that may be.