命令模式execute方法中的参数个数 [英] command pattern variable number of parameters in execute method

查看:336
本文介绍了命令模式execute方法中的参数个数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个银行帐户程序并使用命令模式,其中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.


展开 | 选择 | Wrap < span class =codeDivider> | 行号


所以我''我没有走好路?

我的命令出了什么问题?
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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆