“cannot find symbol - class Scanner” error

前端 未结 7 1584
醉话见心
醉话见心 2020-12-18 00:04

This is my Code

public class Workshop3
{
    public static void main (String [] args)
    {
        System.out.println (\"please enter radius of circle\");
          


        
相关标签:
7条回答
  • 2020-12-18 00:11

    Please add the following line on top of your code

    *import java.util.*;*
    

    This should resolve the issue

    0 讨论(0)
  • 2020-12-18 00:17

    You need to include the line import java.util.Scanner; in your source file somewhere, preferably at the top.

    0 讨论(0)
  • 2020-12-18 00:22

    You have to import java.util.Scanner at first line in the code

    import java.util.Scanner;
    
    0 讨论(0)
  • 2020-12-18 00:22

    sometimes this can occur during when we try to print string from the user so before we print we have to use

    eg: Scanner scan=new Scanner (System.in);

    scan.nextLine(); // if we have output before this string from the user like integer or other dat type in the buffer there is /n (new line) which skip our string so we use this line to print our string

    String s=scan.nextLine();

    System.out.println(s);

    0 讨论(0)
  • 2020-12-18 00:23

    You can resolve this error by importing the java.util.* package - you can do this by adding following line of code to top of your program (with your other import statements):

    import java.util.*;
    
    0 讨论(0)
  • 2020-12-18 00:30

    Add import java.util.Scanner; at the very top of your code. Worked for me.

    0 讨论(0)
提交回复
热议问题