命令模式execute方法中的参数个数 [英] command pattern variable number of parameters in execute method
问题描述
我想写一个银行帐户程序并使用命令模式,其中execute方法有可变数量的参数。
[code]
public interface Command {
public abstract void execute(String ... s);
}
[code]
如何获取传递给该方法的参数?
何时执行方法调用?
i want to write a bank account programme and use a command pattern where execute method has variable number of parameters.
[code]
public interface Command {
public abstract void execute (String ... s);
}
[code]
how do i get the parameters passed to that method?
when is the execute method called?
推荐答案
i想要编写一个银行帐户程序并使用命令模式,其中execute方法具有可变数量的参数。
i want to write a bank account programme and use a command pattern where execute method has variable number of parameters.
所以我''我没有走好路?
我的命令出了什么问题?
so i''m not on a good path?
what''s wrong with my Command?
所以我没有走好路?
我的命令出了什么问题?
so i''m not on a good path?
what''s wrong with my Command?
这就是我在之前的回复中所写的内容,但也许情况并非如此糟糕。
这些字符串是什么意思?每个Command都可以使用一个可变数字
的字符串,或者字符串的数量取决于*哪个*命令是
要执行?
亲切的问候,
Jos
That''s what I wrote in my previous reply, but maybe things are not so bad.
What do these Strings mean? Can every Command take a variable number
of Strings or are the number of Strings depending on *which* Command is
to be executed?
kind regards,
Jos
这篇关于命令模式execute方法中的参数个数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!