These code gives
error message "Main.java:3: error: '{' expected public class Bister.java {
1 error"
I can't understand "why is come up ?" .
import java.util.Scanner;
public class Bister.java {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int num1 = in.nextInt();
System.out.print("Input second number: ");
int num2 = in.nextInt();
System.out.println(num1 + " x " + num2 + " = " + num1 * num2);
}
}
答案 0 :(得分:1)
Remove .java in source code. change below line
public class Bister.java {
like this
public class Bister {
Your code will be like
import java.util.Scanner;
public class Bister {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("Input first number: ");
int num1 = in.nextInt();
System.out.print("Input second number: ");
int num2 = in.nextInt();
System.out.println(num1 + " x " + num2 + " = " + num1 * num2); }
}
答案 1 :(得分:1)
If you call the file Main.java
, it should contain public class Main {
.
If you want it to be public class Bister {
, the file has to be Bister.java
And the .java
appears in the filename only, it is not part of the source code.
答案 2 :(得分:0)
You need to do two things:
Remove .java in class name Current code: public class Bister.java Update to : public class Bister
Also your file name should be "Bister.java".