Compile Error
/in/Main.java:2: error: class Test is public, should be declared in a file named Test.java public class Test ^ 1 error
代码
import java.util.*;
public class Test
{
public static void main(String[] args)
{
System.out.println("请输入一个数:");
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int result = 1;
for(int i = 1;i<=num;i++)
{
result *= i;
}
System.out.println(num+"这个数的阶乘为:"+result);
}
}