0
import java.util.*;
public class add {

    public static void main (String args[]){

        Scanner.Sc = new Scanner(System.in);
        int a = Sc.nextInt();
        int b =  Sc.nextInt();
        int sum=  a+b;

        System.out.println(sum);





    }
    
}

Problem:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
        Sc cannot be resolved or is not a field
        Sc cannot be resolved
        Sc cannot be resolved

        at add.main(add.java:6)



Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
        Sc cannot be resolved or is not a field
        Sc cannot be resolved
        Sc cannot be resolved

        at add.main(add.java:6)
Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Pallavi
  • 9
  • 3
  • 2
    `Scanner.Sc` would try to reference a nested/inner class called `Sc` inside of `Scanner`. Such a class does not exist. You *probably* meant to write `Scanner Sc` (which would define a variable named `Sc` of type `Scanner`). Also (and that's not a cause for a problem, but just a good suggestion): the naming convention in Java says that variables should start with a lower case letter, so `Scanner sc` is the more common/widely understood way. – Joachim Sauer Apr 15 '23 at 11:25

0 Answers0