how exit from the following infinite loop in java but still fill vector till 100 with unique values?

i want to create vector of big length from unique values without repetition but the following code enter in infinite loop .

public static void main(String[] args) {

// TODO code application logic here

Vector v1=new Vector(100);

Vector v2=new Vector(100);

Random r=new Random();

int i=0;

while(i<100){

double val=Math.abs(r.nextGaussian());

double h=(double)((double)Math.round(val*10)/10.0);

if (!v1.contains(h)){

v1.add(h);

i++;

}

}

for(int j=0;j
v2.set(j, v1.get(j));

}

}...

Read More »

By: StackOverFlow - Sunday, 15 April

Related Posts