用于 3 行值的集合类型,其中 2 行必须相乘

发布于 2024-11-28 18:25:45 字数 492 浏览 0 评论 0原文

我正在从包含三列多行的 SQL 查询返回结果。 Column1(比率)必须乘以Column2(数值)。第 3 列包含五个不同的可能值。每个值将指示第 1 列和第 2 列必须遵守的条件(基本上第 3 列将是另一个值(如汇率)-但尚未确定,所以我想将此值与其他两个值的结果分组。 显然应该使用某种集合,但我不确定这将使我能够有效地处理将column1乘以column2并记下column3的值并在以后相乘。到目前为止,我有这样的事情: (显然生病了可能需要一个for循环)

double value= "column1";
double rate= "column2";
double currency= "column3";

Finalamount setValue(value);
Finalamount setRate(rate);
Finalamount setCurrency(currency);

Collection <Finalamount> col = new ArrayList();

i am returning results from a sql query which contains multiple rows of three columns.
Column1(a rate) must be multiplied by column2(a numerical value). Column 3 consists of five different possible values. Each value will indicate a condition that column1 and column2 must adhere to( basically column3 will be another value (like an exchange rate)- but it has not yet been determined, so I would like to group this value with the result of the other two.
Obviously a collection of some sort ought to be used, but i am not sure which will allow me to efficiently deal with multiplying column1 by column2 and noting the value for column3 and multiplying this at a later date. So far, I have something like this:
(obviously ill probably need a for loop)

double value= "column1";
double rate= "column2";
double currency= "column3";

Finalamount setValue(value);
Finalamount setRate(rate);
Finalamount setCurrency(currency);

Collection <Finalamount> col = new ArrayList();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风向决定发型 2024-12-05 18:25:45

您应该编写一个自定义类,将所有这些从客户端中抽象出来。它将记录和封装需要完成的操作,并简单地处理它,以便当客户端返回查询结果时一切都已设置完毕。

You ought to write a custom class that abstracts all this away from clients. It'll document and encapsulate what needs to be done and simply handles it so it's all set when clients get the query results back.

孤凫 2024-12-05 18:25:45

看起来您已经走在正确的轨道上了。只需输入您的数组列表并为其指定一个更好的名称:

Collection <Finalamount> finalAmounts = new ArrayList<Finalamount>();

Looks like you're already on the right track. Just type your array list and give it a better name:

Collection <Finalamount> finalAmounts = new ArrayList<Finalamount>();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文