且构网

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

从Java中的函数返回多个值

更新时间:2023-08-22 21:27:52

创建一个包含所需多个值的类。在您的方法中,返回一个对象,该对象是该类的实例。瞧!

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.