
public class Random
{
private static final long p = 4611686018427388039L; // First prime > 262
private static final long f = 1729;
private static final long seed = System.currentTimeMillis;
private static Random instance = new Random();
private long last;
private Random()
{
last = seed;
}
public long next()
{
last = (last * f) % p;
return last;
}
public static Random getInstance()
{
if (instance == null)
instance = new Random();
return random;
}
}
How do you get a random number generator?public static final Random INSTANCE = new Random();
public class Random {
public static final Random INSTANCE = new Random();
private static final long p = 4611686018427388039L;
private static final long f = 1729;
private static final long seed = System.currentTimeMillis();
private long last;
private Random()
{
last = seed;
}
public long next()
{
last = (last * f) % p;
return last;
}
public static void main(String[] args)
{
System.out.println(Random.INSTANCE.next());
}
}
public class Random
{
private static final long p = 4611686018427388039L;
private static final long f = 1729;
private static final long seed = System.currentTimeMillis();
public static final Random INSTANCE = new Random();
private long last;
private Random()
{
last = seed;
}
public long next()
{
last = (last * f) % p;
return last;
}
public static void main(String[] args)
{
Random random = null;
System.out.println(random.INSTANCE.next());
}
}
null.INSTANCE.next();
public class Random {
private static final long p = 4611686018427388039L;
private static final long f = 1729;
private static final long seed = System.currentTimeMillis();
private static long instances;
private long last;
private Random() { last = seed; instances++; }
public long next()
{
last = (last * f) % p;
return last;
}
public static long instances() { return instances; }
public static void main(String[] args)
{
int n = 1_000_000;
for (int i = 0; i < n; i++)
long random = new Random().next();
System.out.println(Random.instances());
}
}
IntStream.range(0, n).parallel().forEach(i -> new Random().next());

mkdir marvin cd marvin jar xvf ~/Downloads/MarvinFramework*.zip
FirstApplication.java with this code. Compile with
javac -classpath marvin/framework/marvin_1.5.3.jar FirstApplication.java
res/test.jpg
java -classpath .:marvin/framework/marvin_1.5.3.jar FirstApplication
marvin_1.5.3.jar as an external JAR: Right-click on project → Properties → Java Build Path → Libraries → Add External JARs...cd ~ jar xvf Downloads/junit4.11.zip
hw6b and put the files SpinningDisk.java and SpinningDiskTest.java there.cd ~/hw6b javac -cp .:~/junit4.11/junit-4.11.jar SpinningDiskTest.java
java -cp .:~/junit4.11/\* org.junit.runner.JUnitCore SpinningDiskTest
java -cp .:~/junit4.11/junit-4.11.jar . . .? Because JUnit also needs another JAR in that directory to run.