+ 1
Math.random error!
Here's a copy of my code: ... import java.util.Scanner; import java.util.Random; public class Program { public static void main(String[] args) { String[] words = {"With","Hi","Down"}; int pos = (int ) Math.random() * words[].length; } } ... The math.Random() section keeps throwing an error -- something about expecting a class. Anyway, I've been trying different variations of this for a while, following the general guidelines given here and on other places in the internet. Help?
1 Resposta
+ 5
Nope not error.Just it must be
import java.util.Scanner;
import java.util.Random;
public class Program
{
public static void main(String[] args) {
String[] words = {"With","Hi","Down"};
int pos = (int ) Math.random() * words.length;
}
}
Remove array bracket of words.length