Hi again, would like to consult about List problem.
//start code
// we're in the 'getMonitor' method
Now what happen is I need to call those fields above in a method ‘report’
(in the same file – TestDriver.java ). Here comes my question:
1. How am I supposed to call single value/position without call Entry as a whole?
E.g: I want to compare value of index 1 and index 0 - which I have read inputs from Array.
Please advise me. thanks guys...
//start code
Code:
java.util.List ifs = new java.util.ArrayList();
Code:
Instruction insn = jvm.getLastInstruction();
………
………
if (insn instanceof IfInstruction)
{
IfInstruction iff = (IfInstruction) insn;
Object position = insn.getOffset();
boolean value = iff.getConditionValue();
ifs.add(new Entry(position, value));
System.out.print(position);
System.out.println();
System.out.print(value);
System.out.println();
Iterator iter = ifs.iterator();
while (iter.hasNext()) {
System.out.println("string " + iter.next());
}
System.out.print(ifs.size());
System.out.println();
}
// ... the rest of the method are here
Code:
class Entry {
public Object position;
public boolean value;
public Entry(Object position, boolean value) {
this.position = position;
this.value = value;
}
}
(in the same file – TestDriver.java ). Here comes my question:
1. How am I supposed to call single value/position without call Entry as a whole?
E.g: I want to compare value of index 1 and index 0 - which I have read inputs from Array.
Code:
void report( )
………
………
//ifs.get(1) != ifs.get(0)
//I don't need this because it is getting compare the
//whole Entry.I need something like this:
if (ifs.value(1) != ifs.value(0)) //For sure errors encountered!
{
System.out.println (“A”);
}
else
{
System.out.println (“B”);
}
Comment