Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何Set<String>将同一方法中的两个单独的迭代值返回给Futuremain 方法中的对象?我正在使用Callable,因为我必须返回一组字符串值并将它们存储起来以供进一步使用。
Set<String>
Future
Callable
如果我理解这个问题,那么当您想从任何方法返回多个值时也是一样的。您始终可以创建一个包含任意数量Set值的包装类,并从您的Callable.
Set
private static class MultiSet { Set<Integer> set1; Set<Integer> set2; } private static class MyCallable implements Callable<MultiSet> { public MultiSet call() { ... } }