Dillon Dillon - 16 days ago 7
Java Question

Java how to import .util into created package

I decided to created a new package and i made class inside that package and tried to Import java.util.Random and it gives me an error "syntax error on token "package", . Expected.

Typing Import java.util.Random Worked in the default package

Answer

The package should come before the import

package ballhockeymanagergame;
import java.util.Random;

public class Main { public static void main(String[] args) { } }