Hi all,
I have a problem with my code when I add this line:
inject=aRandom.nextBoolean();
I have a loop more than what it is supposed to be. Iterations should stop at 10 but it continues until it reaches 13 or 15.
Here is my code:
import java.util.Random; public class Test1_FT1 { static boolean inject=true; static boolean previnj=true; static Random aRandom = new Random(); public static boolean check(int v1, int v2){ inject=aRandom.nextBoolean(); if(v1<v2){ if(inject){ return false; } else return true; } if(inject) return true; return false; } static int nmax=10; public Test1_FT1() { int i=0; while((check(i,nmax))!=(check(i,nmax))); while((check(i,nmax))) { System.out.print("nmax: "); System.out.print(nmax+"\n"); i++; } } public static void main(String[] args) { new Test1_FT1(); } }