factorialimpl.java
来自「书籍《JAVA面向对象程序设计》书籍的课后源代码。相信对很多人都有帮助」· Java 代码 · 共 26 行
JAVA
26 行
/////// FactorialImpl.java ///////
package myrmi.demo;
import java.rmi.*;
import java.rmi.activation.*;
public class FactorialImpl extends Activatable
implements Factorial
{
public FactorialImpl(ActivationID id, MarshalledObject data)
throws RemoteException
{
super(id, 0);
}
public int factorial(int n)
throws RemoteException
{
if ( n < 0 )
throw( new RemoteException(
"Arg to factorial cannot be negative."));
return ( n == 0 ) ? 1
: n*factorial(n-1);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?