Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Class 1

Status
Not open for further replies.

andypara

Programmer
Apr 25, 2002
32
0
0
GB
Can some one tell me why the following code :-

class ArrayBasics {
public static void main(String args[])
{
int dynamicMulti[][];
dynamicMulti = new int[3][7];

for (int i = 0; i < dynamicMulti.length; i++)
{
for (int j = 0; j < dynamicMulti.length; j++)
{
int a = Random.nextInt(11);
dynamicMulti[j] = a;
System.out.print(dynamicMulti[j]);
};
System.out.println(&quot;&quot;);
};

}
}

gives the following error :-

symbol : variable Random
location: class ArrayBasics
int a = Random.nextInt(11);
^
1 error
 
First of all u need to import
import java.util.Random;

Next is u cannot access the method nextInt as it is not a static method. have a object instantiated and then do it...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top