扫描仪导入问题显然

时间:2014-09-26 08:16:32

标签: java netbeans java.util.scanner

import java.util.Scanner;
public class JavaApplication1 {
    public static void main (String[] args)
    {
        System.out.println ("You will be prompted to enter the lengths of your triangle, do this in no particular order");

        *Scanner sc = new.Scanner(System.in);
    }
}

为什么我在标记的Scanner行上收到错误消息?我无数次地完成了这件事。它一直告诉我它需要一个标识符。发生了什么事?

2 个答案:

答案 0 :(得分:1)

应该是

Scanner sc = new Scanner(System.in);

Scanner sc = new.Scanner(System.in); // . is invalid

.应该替换为空格。没有*以及

答案 1 :(得分:0)

我犯了一个简单的错误。更正的代码是:

import java.util.Scanner;
public class JavaApplication1 {
public static void main (String[] args)
{
    System.out.println ("You will be prompted to enter the lengths of your triangle, do this in no particular order");

    Scanner sc = new Scanner(System.in);
}