java - 排队存储有关交易的成本
问题描述
我打算将这些值中的 6 个存储在一个队列中,当它达到限制 6 时,它将执行 FIFO 测量。
我的问题是如何显示字符串数据类型的详细信息,例如交易名称、涉及的公司等。我显然不能在队列中这样做;只保存一种数据类型。
//Both are declared in a class
private float Amount;
Queue <Float> Transactions = new LinkedList <Float>();
//In a method via a parameter to add to a queue
Transactions.offer(Cost);
新示例:
public void New_Transaction(String Transaction, float Cost, String
Date_Time) {
Transaction_Type = Transaction;
Transactions.offer(Cost);
Date_an_Time = Date_Time;
}
解决方案
您使用事务名称、所涉及的公司和其他名称创建一个对象作为字段,然后将该对象用作队列事务的数据类型。希望这可以帮助。
推荐阅读
- react-native - 使用可重用函数组件反应原生条件样式 onFocus onBlur
- python - YOLO v4 边界框和标签排序
- cassandra - 如果发生节点故障,数据将如何同步
- arrays - 将 Pytorch 的张量元素转换为“float”类型而不是“double”类型
- java - 基于GSON中字段名的同类型序列化,无注解
- python - ffpyplayer ImportError:导入播放器时DLL加载失败
- django - 在 django 中获取与选定外键相关的项目
- java - Java Spring 规范嵌套连接条件
- amazon-web-services - VPC 终端节点无法连接到共享 AWS 账户中的 S3
- python - 基于键将字典值组合在一起