Java Problem

Discussion in 'Mac Programming' started by CayceH, Feb 25, 2012.

  1. CayceH
    Expand Collapse
    macrumors newbie

    Dec 23, 2011
    United States
    import java.util.Scanner;

    public class HelloWorld {
    public static void main(String[] args) {
    Scanner keyboard = new Scanner(;
    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?
  2. lee1210
    Expand Collapse
    macrumors 68040


    Jan 10, 2005
    Dallas, TX

Share This Page