Hi,
I have some problems with Random(). My code is as follows.
Random random = new Random();
private int rand(int scale) {
return (random.nextInt() << 1 >>> 1) % scale;
}
Whenever I write something like:
int number = rand(9);
It has null pointer exception.
But if I use the above rand() function without assigning it to an integer, it works. eg:
g.drawString("Number: " + rand(9), 0, 0, Graphics.LEFT | Graphics.TOP);
Would you please tell me what is wrong?
Thank you
Nelson

Reply With Quote

