Home » Java ThreadLocalRandom setSeed() Method with Examples

Java ThreadLocalRandom setSeed() Method with Examples

by Online Tutorials Library

Java ThreadLocalRandom setSeed() method

The setSeed() method of Java ThreadLocalRandom class throws UnsupportedOperationException. In this generator, setting seeds is not supported. This method overrides setSeed in class Random.

Syntax:

Parameter:

seed: It is the initial seed

Exception:

UnsupportedOperationException: This exception will throw always.

Example 1

Test it Now

Output:

Exception in thread "main" java.lang.UnsupportedOperationException  at java.base/java.util.concurrent.ThreadLocalRandom.setSeed(Unknown Source)  at tests.JavaDateSetTimeExample1.main(ThreadLocalRandomSetSeedExample1.java:8)  

You may also like