Viscocent Viscocent -4 years ago 194
Java Question

import java.util.Random does not exist

New on Eclipse and learning the Java basics. I'm fond of PHP so I don't really have problems with the syntax, but when I try to use

rand = new Random
, the
goes red even if I declare
import java.util.Random
on the top of my class. Am I missing something?

import java.util.Random;
public class Forge {
int chance = 0;

public static void main(String[] args){
rand = new Random;

Random goes red and also my CTRL+SHIFT+O does not work when I try to import something on my class.

Answer Source

For creating object you need to do

Random rand=new Random();

You have forgotten to add () in this line rand = new Random;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download