Code:
public class Result
{
private int countA = 0;
private int countB = 0;
private int statement;
private boolean statusA = false;
private boolean statusB = false;
[B]private int[] arrayA = new int[2]; [B]<= the problem seem like happen at here?[/B]
private int[] arrayB = new int[2];[/B] [B]<= the problem seem like happen at here?[/B]
public Result()
{
}
public void setA(int valueA)
{
countA = valueA;
}
public void setB(int valueB)
{
countB = valueB;
}
public void setOption(int stm)
{
statement = stm;
}
public void setStatusA(boolean a)
{
statusA = a;
}
public void setStatusB(boolean b)
{
statusB = b;
}
public void resetToFalse()
{
statusA = false;
statusB = false;
}
public void sumTotal()
{
if(statement==1)
{
if(statusA == true)
{
int temp = arrayA[0];
arrayA[0] = temp + 1;
[B][I]System.out.println("arrayA[0] is: " + arrayA[0]);[/I][/B] [B]<= This line can correctly show increament of the array value everytime i click one time buttonA from another class[/B]
}
if(statusB == true)
{
int temp = arrayA[1];
arrayA[1] = temp + 1;
[B][I]System.out.println("arrayA[1] is: " + arrayA[1]);[/I][/B] [B]<= This line can correctly show increament of the array value everytime i click one time buttonB from another class[/B]
}
}
if(statement==2)
{
if(statusA == true)
{
int temp = arrayB[0];
arrayB[0] = temp + 1;
System.out.println("arrayB[0] is: " + arrayB[0]);
}
if(statusB == true)
{
int temp = arrayB[1];
arrayB[1] = temp + 1;
System.out.println("arrayB[1] is: " + arrayB[1]);
}
}
}
[I][B]public void printReport()
{
System.out.print(arrayA[0] + " " + arrayA[1] + "\n");
System.out.print(arrayB[0] + " " + arrayB[1]);
}[/B][/I]
}
arrayA: 0 0
arrayB: 0 0
May i know what is the problem cause the output become zero value even though code at line 48 and 54 can print out correct updated output.
Comment