+ 3

Whats wrong here

class Math{ public static void main (String []args) { double x = Math.random(); System.out.println(x); } }

2nd Aug 2018, 10:37 AM
Zawad Abu
Zawad Abu - avatar
3 Respostas
+ 5
i'm assuming that it's the fact you named your class math and didn't define a random() method within it
2nd Aug 2018, 10:42 AM
hinanawi
hinanawi - avatar
+ 2
Because your class name is Math, the compiler will seek random in your class first.To make it right by a easy way, I think you should rename your class.
2nd Aug 2018, 11:36 PM
Xhy
Xhy - avatar
0
The Math class is a predefined class in Java. You are creating another Math class without the random method and calling it instead of calling the other Math class
7th Aug 2018, 8:35 AM
Anon Anon
Anon Anon - avatar