I put off asking this as it must be something daft and, given it was also me who asked this, I hesitated and have spent the last few hours getting increasingly frustrated:
Last line of for loop executed twice?
I think it might be a similar sort of oversight.
I also found this, which deals with a similar problem:
Java Exception printing twice
but still can’t seem to fix mine.
Here is a snippet from one class:
switch (Integer.parseInt(oc, 16))
{
case 0x0F:
ccrFlagState.zBit(true);
break;
}
Which calls this snippet in another:
public boolean zBit(boolean set) {
if (set = true) {
System.out.println("Z set in CCR class");
}
return set;
}
When I input 0F the console prints Z set in CCR class twice.
Can anyone point me in the right direction as to why? Thanks, Robert.
-EDIT-
I should add that I get the same result with:
if (set)
and
if (set == true)
This is not reproducable for me. This code only pints it out once. Please provide more code …