Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7728243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:40:11+00:00 2026-06-01T05:40:11+00:00

The next method of java.util.Random , when I view source in Eclipse, is essentially:

  • 0

The next method of java.util.Random, when I view source in Eclipse, is essentially:

seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1);
return (int)(seed >>> (48 - bits));

How can I determine if different JDKs or JVMs will implement next in a different way or with different constants?

I have already come across different no-argument constructors in Weird behaviour when seeding Java Random. I want to know if a similar thing might occur with the next method. Where can I find the source to different implementations?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:40:13+00:00Added an answer on June 1, 2026 at 5:40 am

    The Javadoc for Random.next() explicitly states which algorithm is used to generate the next number.

    It is theoretically possible that a different JVM might use a different algorithm, but this is unlikely, especially if you restrict yourself to JVM’ that are based on the Sun / Oracle libraries.


    Does that documentation necessarily apply to all JDKs?

    You’d need to check to be sure, but probably yes. This is the kind of thing that Sun / Oracle are unlikely to change because of the potential for breaking lots of existing Java applications and test suites written over that last 15 or so years.

    Here are some facts:

    • the javadoc for Java 1.3.1 through Java 1.7 (*) contains the exact same specification for this method,

    • an implementation is only permitted to use the trademark “Java” if it conforms to the specification

    • most (if not all) Java(TM) implementations use class libraries that are derived from the Oracle / Sun source code,

    • developers would notice that a different algorithm was used … and complain loudly.

    So the likelihood of a Java(TM) implementation using a different algorithm is pretty small.

    (* I couldn’t find the Java 1.1 javadocs online, but I expect that they will say the same thing.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the java.util.Set interface lack get(int Index) , or any similar get() method?
Create a method named getNextProjectIndex() that returns an int that gets the next index
I want to execute a job everyday 2PM. Which method of java.util.Timer I can
Is java.util.logging.Logger.log() is a chain of responsibility pattern?If so how log method call is
Exception in thread Thread-8 java.lang.StackOverflowError at sun.misc.Unsafe.compareAndSwapLong(Native Method) at java.util.concurrent.atomic.AtomicLong.compareAndSet(Unknown Source) at java.util.Random.next(Unknown Source)
I just saw the code of contains method in java.util.Hashtable.java. It has a loop
In Watir you can get WIN32OLE handle of IE window using next method. irb(main):059:0>
I have an application (ASP.NET MVC) that uses a Next New method to get
I need to call a method I have defined as: -(IBAction)next:(id)sender{ ... } I
SqlDataReader.Read() is a method which returns a bool but advanced to the next record

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.