简体   繁体   中英

cannot find symbol variable keyboard of type scanner

I keep getting cannot find symbol errors. I've tried everything that was previously suggested with no luck. I feel like I'm missing something really simple!

import java.util.Scanner;

public class XXX
{
   public static void main(String[] args)
   {
      String playerName1;
      final int MIN_SCORE = 19;
      final int MAX_SCORE = 51;
      int score;

      Scanner keyboard = new Scanner(System.in);

      System.out.println();
      System.out.print("Enter you name: ");
      playerName1 = keyboard.next();

      System.out.print("Welcome" + playerName1 + "to the game of guts! ");

      System.out.println();

      System.out.print("Enter winning Score(between 20 - 50): ");
      score = keyboard.Int();

   }
}



ProgrammingProject3.java:36: error: cannot find symbol
      score = keyboard.Int();
                      ^
  symbol:   method Int()
  location: variable keyboard of type Scanner

AScanner indeed doesn't have an int() method. It's called nextInt() .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM