Void value as return parameter

后端 未结 8 2509
夕颜
夕颜 2021-02-19 18:50

I have this interface:

public interface Command {
    T execute(String... args);
}

it works fine for most uses. But when I try to mode

相关标签:
8条回答
  • 2021-02-19 19:28

    I would stick to using Void explicitly. It's easy to see what is going on without another class involved. It'd be nice if you could override a Void return with void (and Integer with int, etc), but that is not a priority.

    0 讨论(0)
  • 2021-02-19 19:33

    That problem is not that common, but neither that rare... I think I've seen a discussion about that some time ago, about Callables that return nothing.

    I agree with the other posters that this is a good solution, much better than using Object or some other dummy placeholder.

    0 讨论(0)
提交回复
热议问题