Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

CayceH

macrumors newbie
Original poster
Dec 23, 2011
15
0
United States
import java.util.Scanner;

public class HelloWorld {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Choose a number between 1 and 10");
if (keyboard == 1) { System.out.println("You are correct");
} else System.out.println("Sorry try again");
}
}


it says i can not have (keyboard == 1) so i tried to declare keyboard as an int but received another error how do i make it to where if someone types 1 on the keyboard that it will run the command?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.