Results 1 to 5 of 5
- 10-10-2011, 09:34 AM #1
Member
- Join Date
- Oct 2011
- Posts
- 19
- Rep Power
- 0
error compiling program for Random Numbers
Hi,
I am compiling the following code,
And I get the following error while compiling it...Java Code:public class Random{ public static void main(String[] args) { Random ran = new Random(); int number = ran.nextInt(); System.out.println(number); } }
Can you help ?Java Code:C:\Subbu\Java>javac Random.java Random.java:4: error: cannot find symbol int number = ran.nextInt(); ^ symbol: method nextInt() location: variable ran of type Random 1 error
- 10-10-2011, 09:42 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: error compiling program for Random Numbers
Your class Random has nothing to do with the Random class you find in the SE distribution; rename your class.
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-10-2011, 09:48 AM #3
Member
- Join Date
- Oct 2011
- Posts
- 19
- Rep Power
- 0
Re: error compiling program for Random Numbers
Thanks, but still the same...
- 10-10-2011, 09:49 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,606
- Blog Entries
- 7
- Rep Power
- 17
Re: error compiling program for Random Numbers
Do you still have a stray Random.class somewhere? Delete it and import the correct Random class (it's in the java.util package).
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 10-10-2011, 09:56 AM #5
Member
- Join Date
- Oct 2011
- Posts
- 19
- Rep Power
- 0
Similar Threads
-
Is Random() Only For Numbers?
By Salamander in forum New To JavaReplies: 2Last Post: 02-07-2011, 10:02 AM -
Java program problem.. Arrays.. Random Numbers
By Chewart in forum New To JavaReplies: 16Last Post: 11-16-2009, 10:21 PM -
How do I generate random numbers in a certain range using the random class?
By frasifrasi in forum New To JavaReplies: 8Last Post: 04-19-2009, 05:50 PM -
random numbers without random class`
By carlos123 in forum New To JavaReplies: 4Last Post: 01-17-2008, 10:44 PM -
random numbers
By carlos123 in forum New To JavaReplies: 1Last Post: 12-22-2007, 02:56 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks