public class happy { public static void main(String[] args) { Scanner num = new Scanner (System.in); int first, second, result; System.out.print("Enter first num: "); first = num.nextInt(); System.out.print("Enter second num: "); second = num.nextInt(); result = first + second; System.out.println("It is" + result + "!!!"); } } 
 happy.java:3: error: cannot find symbol Scanner num = new Scanner (System.in); ^ symbol: class Scanner location: class happy happy.java:3: error: cannot find symbol Scanner num = new Scanner (System.in); ^ symbol: class Scanner location: class happy 2 errors 

Closed due to the fact that off-topic participants Sergey Gornostaev , D-side , Peter Samokhin , MSDN.WhiteKnight , 0xdb May 28 '18 at 21:13 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - Sergey Gornostaev, D-side, Peter Samokhin, MSDN.WhiteKnight, 0xdb
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    I just launched it and it all worked for me. To avoid such confusion, also lay out a compiler error message. - pinguin
  • happy.javaUE: error: cannot find symbol Scanner num = new Scanner (System.in); ^ symbol: class Scanner location: class happy happy.javaUE: error: cannot find symbol Scanner num = new Scanner (System.in); ^ symbol: class Scanner location: class happy 2 errors - Tetyana Tsishkovska
  • Nothing is clear - ishidex2

1 answer 1

Maybe the Scanner class was not imported?

  • @AlexChermenin, this is actually the answer. - Qwertiy
  • @Bakhuss can not, but just lacks the line import java.util.Scanner; - Oleg Sukhikh
  • @Qwertiy it seems to me that either this is a comment with a clarifying question, or then there should not be a question in the answer - Alex Chermenin
  • @AlexChermenin I am a newbie here, so I designed it in the form of a question, which with a high degree of probability gives a positive answer. :) - Bakhuss
  • @Bakhuss ok, so be it :) - Alex Chermenin