i was using If-Else Statement in my validation function.
I had a validation class with all the validation functions then i accessed these methods via the object of the Validation class .
what happened is that the control was going inside both the conditions
if(some cond ..)
System.out.println("inside IF");
else
System.out.println("inside ELSE");
I also tried
if(some cond ..)
{
System.out.println("inside IF");
}
else
{
System.out.println("inside ELSE");
}
in both the cases the control was going inside both the conditions and printing both the lines.
I could not explain this to my self , no matter what condition i give if this is not a syntax error it should only go in either of the loop but not both
CAN ANYBODY EXPLAIN HOW CAN IT BE POSSIBLE THAT BOTH THE IF AND ELSE CONDITIONS BEING EXECUTED ???
I made some other irrelevant changes in my project and after some time it was working fine , but at that time i could not explain my self how it was possible
btw if it matters , i was using this class inside a android project thus android compiler was being used
You mean if-else conditional statements, not loops.
It sounds like a threading issue. You probably have a thread that goes on one route, while another one calls the same method and goes on the other path. This is how you can get both strings displayed.
In order to debug this, you could print
Thread.currentThread()at the end of eachSystem.out.printlncall. I’m sure you will see differentThreadobject addresses.