错误整数定制值Java

时间:2018-04-30 13:48:15

标签: java class input compiler-errors main

如何在以下程序中读入整数?它不起作用。它目前无法编译。

/**
 * Main class of the Java program. 
 * 
 */
import java.util.Scanner;

//...
class Scanner{
    Scanner in = new Scanner(System.in);
    int num = in.nextInt();
}


public class Main {

    public static void main(String[] args) {

        // we print a heading and make it bigger using HTML formatting
        System.out.println("<h4>-- Binaere Suche --</h4>");
        int anzahl = 0; int zahl;

    }
}

1 个答案:

答案 0 :(得分:0)

import java.util.Scanner;

// This will print what you want but will not make it look bigger as it
// will get printed in console
public class Main {

    public static void main(String[] args) {

    Scanner in = new Scanner(System.in);
    int num = in.nextInt();
 // we print a heading and make it bigger using HTML formatting
        System.out.println("<h4>--"+num+" --</h4>");

    }
}