import java.io.*;
public class factorial{
public static void main(String[] args) {
System.out.println("Please enter a integer:");
double n=0;
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
String s=in.readLine();
n=Double.parseDouble(s);
}catch(IOException e){}
factorial r=new factorial();
double m=r.factorial1(n);
System.out.println("!"+n+"="+m);
}
static double factorial1(double k){
double m=1;
for(;k>0;k--)
m*=k;
return m;
}
彩色部分 编译器说This static method factorial1(double)form the type factorial shoud be accessed in a static way
但是能够通过运行 请帮我解释一下 啊 谢谢!
public class factorial{
public static void main(String[] args) {
System.out.println("Please enter a integer:");
double n=0;
try{
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
String s=in.readLine();
n=Double.parseDouble(s);
}catch(IOException e){}
factorial r=new factorial();
double m=r.factorial1(n);
System.out.println("!"+n+"="+m);
}
static double factorial1(double k){
double m=1;
for(;k>0;k--)
m*=k;
return m;
}
彩色部分 编译器说This static method factorial1(double)form the type factorial shoud be accessed in a static way
但是能够通过运行 请帮我解释一下 啊 谢谢!
double m=r.factorial1(n); 类名+方法名factorial.factorial1(n);