my dog learned polymorphism*
The moose likes Beginning Java and the fly likes What's wrong with this code??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What Watch "What New topic
Author

What's wrong with this code???

Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
The code below:-
class RandomArray{
public static void main (String args[] )
{
double[] samples = new double[50];
for (int i=0; i <50; i++)
samples[i] = 100.0*Math.randon();
double average = 0.0;
for (int i=0; i <50; i++)
average += samples[i];
average/= 50;
System.out.print(average);

}
}
gives me the following error when i try and compile it:
"RandomArray.java": Error #: 300 : method randon() not found in class java.lang.Math at line 10, column 25
I'm using JBuilder

Can anyone see what i'm doing wrong?


John Bonham was stronger, but Keith Moon was faster.
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
You spelled the method name wrong. The Math class does not have a method named randon. It does, however, have a method named random. One letter makes a big difference in java.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Robbie shi
Greenhorn

Joined: Jan 05, 2003
Posts: 28
100.0*Math.randon();
wowow~~
wrong spelling~~
you have to care about your code~
--
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
Steve Jensen
Ranch Hand

Joined: Sep 23, 2002
Posts: 126
Tsk!
Silly me!!

Sorry.......
 
Don't get me started about those stupid light bulbs.
 
subject: What's wrong with this code???