Skirsch Skirsch - 11 months ago 42
Java Question

I keep getting an <identifier> expected error

I get an

expected error running this code:

public class RockPaperScissors {

public static double aiChoice() {
return Math.random();


Answer Source

The problem is that you have System.out.println(aiChoice); outside any methods and try to print a method without calling it. Instead, put your System.out.println into the main method, like this:

public static void main(String [ ] args) {

Note the parantheses after aiChoice, making sure that you call the method. If your main method does not know about the RockPaperScrissors class, then make sure to

import RockPaperScrissors;

at the start of the file where you have your main method.