什么数据类型支持这种操作?

时间:2012-05-11 00:59:46

标签: java

我目前正在编写一台机器模拟器,这台机器有256个寄存器,每个寄存器都有自己独特的名称,索引和数据。什么样的数据类型会支持这种操作?

以下是一些示例操作:

String output = Registers.RegA.data.toString(); //Returns the value of RegA
System.out.println(output);

Registers A = Registers.RegA; //points A to RegA
Registers AA = Registers.at(0) //Index access Registers, which returns RegA in this case.

A.data = new DataObj("I am a pie");
output = AA.data.toString(); //A and AA both point to RegA, therefore they share the same data
System.out.println(output);
//Expected output: "I am a pie"

output = Registers.RegA.data.toString(); //RegA data is shared across the system
System.out.println(output);
//Expected output: "I am a pie"

上述操作支持哪种数据类型?

1 个答案:

答案 0 :(得分:1)

您可以在此处创建具有多种不同数据类型的class,这些数据类型在合并后将为您所需的操作提供支持。

不是can I find something that does everything I need?的情况,而是what do I need to combine to make this happen?