Hello -
This is a basic simulation of my problem.
I have two classes, and a variable in one gets set, yet generates a NullPointerException.
Test.java, with my main
Ooba.java, where the problem occurs
My error:
Exception in thread "main" java.lang.NullPointerException
at Ooba.generate(Ooba.java:19)
at Test.main(Test.java:7)
Line 19 is the line where I print the next double from the Random.
Any ideas?
Thanks
This is a basic simulation of my problem.
I have two classes, and a variable in one gets set, yet generates a NullPointerException.
Test.java, with my main
public class Test { public static void main(String[] args) { Ooba o = new Ooba(); o.generate(); } }
Ooba.java, where the problem occurs
import java.util.Random; public class Ooba { private Random r; public Ooba() { new Ooba(System.currentTimeMillis()); } public Ooba(long lol) { r = new Random(lol); } protected void generate() { System.out.println(r.nextDouble()); } }
My error:
Exception in thread "main" java.lang.NullPointerException
at Ooba.generate(Ooba.java:19)
at Test.main(Test.java:7)
Line 19 is the line where I print the next double from the Random.
Any ideas?
Thanks