Best code examples for Java 8 Random class (java.util.Random)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Random class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 Random examples from Open Source projects
This code example shows how to use the following methods:
45:	private static final Random RANDOM = new Random(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods:
37:	final Random r = new Random(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: nextLong
77:	rand = myRand.nextLong(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextInt
66:	int val = rnd.nextInt(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextFloat
72:	return pMin + RANDOM.nextFloat() * (pMax - pMin); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextDouble
85:	return valueAt(random.nextDouble()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextGaussian
36:	return (long) Math.abs((RANDOM.nextGaussian() * range) + delay); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextBytes
21:	rand.nextBytes(bytes); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
17:	private static final Random random = new Random(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: nextFloat, nextInt
49:	Random random = new Random(); 
-
51:	calendar.add(Calendar.DAY_OF_YEAR, random.nextInt(25)); 
-
53:	loanQuote.setRate(random.nextFloat() + this.baseRate); 
54:	loanQuote.setTerm(10 + random.nextInt(10)); 
55:	loanQuote.setAmount(250000 + random.nextInt(40000)); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: nextLong
28:	return RAN.nextLong() & MASK; 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextInt
46:	this.finder = new PathFinder(cfg, new Random(rnd.nextInt())); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextFloat
74:	if (generator.nextFloat() < getProbability(klassName)) { 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextDouble
72:	return rand.nextDouble(); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
12:	private static Random rand = new Random(); 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: nextLong
71:	long nextRnd = rnd.nextLong(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextInt
40:	int state = RANDOM.nextInt(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextFloat
71:	return lerp(a, b, sRNG.nextFloat()); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
35:	private final Random mRandom = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextLong
71:	DFSTestUtil.createFile(fs, filePath, fileLen, replicas, rand.nextLong()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextInt
39:	return _random.nextInt(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
39:	"." + (new Random().nextInt()))); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextLong
73:	return idFormat.format(rand.nextLong()); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: nextInt
95:	short randomShort = (short) (rng.nextInt() & 0x7f); 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods:
16:	protected final Random rand = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
58:	private final Random rng = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
33:	private final Random                     random                    = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
34:	private static final Character OBJECT     = (char) (new Random()).nextInt(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
35:	private static final Random rand = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
14:	private Random random = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
44:	private static Random random = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
34:	private static final Random RANDOM = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
92:	new Random().nextBytes(data); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
35:	_random = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
52:	static final Random ran = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
46:	private Random random = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
50:	Random myrand = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
56:	private Random r = new Random(); 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
45:	String name = NAMES[new Random().nextInt(3)]; 
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods:
19:	final Random rand = new Random(); 
Full Snippet Info
9
CodeRank
Related Java 8 Random Questions & Answers:
Other Java 8 Random Examples
15:	  private ObjectAnimator animation2;
16:	  private Button button;
17:	  private Random randon;
18:	  private int width;
19:	  private int height;
-
26:	    width = getWindowManager().getDefaultDisplay().getWidth();
27:	    height = getWindowManager().getDefaultDisplay().getHeight();
28:	    randon = new Random();
29:	
30:	    set = createAnimation();

Read More

12:				// shuffle is on - play a random song
13:				Random rand = new Random();
14:				currentSongIndex = rand.nextInt((songsList.size() - 1) - 0 + 1) + 0;
15:				playSong(currentSongIndex);
16:			} else{
-
12:				// shuffle is on - play a random song
13:				Random rand = new Random();
14:				currentSongIndex = rand.nextInt((songsList.size() - 1) - 0 + 1) + 0;
15:				playSong(currentSongIndex);
16:			} else{

Read More

24:		private static final int MAX_ATTEMPTS = 5;
25:	    private static final int BACKOFF_MILLI_SECONDS = 2000;
26:	    private static final Random random = new Random();
27:	
28:	    /**
-
24:		private static final int MAX_ATTEMPTS = 5;
25:	    private static final int BACKOFF_MILLI_SECONDS = 2000;
26:	    private static final Random random = new Random();
27:	
28:	    /**

Read More

338:	
339:		}
340:	
341:		/**
342:		 * When user starts moving the progress handler
-
338:	
339:		}
340:	
341:		/**
342:		 * When user starts moving the progress handler

Read More

See Code Examples for Java 8 Random Methods: