Void value as return parameter

后端 未结 8 2506
夕颜
夕颜 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:09

    What is interesting in your example is the use of parameterized types. Usually you'd have

    interface Command {
        public T execute(T someObject);
    }
    

    In your case you only have T as a return value. Nevertheless using Void in this case is a good solution. The return value should be null.

提交回复
热议问题