0% found this document useful (0 votes)
47 views1 page

Same Set of Output

This Java code defines a Rand class with a main method that generates random integers between 0-9. The first code block will always produce the same set of random numbers due to setting the Random object with a fixed seed of 1050. The second code block will produce a different set of random numbers on each run as it does not fix the seed.

Uploaded by

avishana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views1 page

Same Set of Output

This Java code defines a Rand class with a main method that generates random integers between 0-9. The first code block will always produce the same set of random numbers due to setting the Random object with a fixed seed of 1050. The second code block will produce a different set of random numbers on each run as it does not fix the seed.

Uploaded by

avishana
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Same set of output

public class Rand {


public static void main(String args[]){
Random rnd = new Random(1050);
for(int i=0;i<5;i++){
System.out.println(rnd.nextInt(10));
}
}

Different set of output


public class Rand {
public static void main(String args[]){
Random rnd = new Random();
for(int i=0;i<5;i++){
System.out.println(rnd.nextInt(10));
}
}

You might also like