helloimpl.java

来自「有关于rmi和 rmi-iiop远程服务器调用的几个实例 包括Fibonacci」· Java 代码 · 共 30 行

JAVA
30
字号
import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory;
import java.rmi.server.UnicastRemoteObject;
import javax.rmi.PortableRemoteObject;

//Service Class
//实现hello接口和java.io.Serializable接口
public class helloImpl extends PortableRemoteObject implements hello {

	public helloImpl() throws RemoteException {
		// TODO Auto-generated constructor stub
	}
	public String hello()
	{
          int i;
          int a[] = new int[10];
	  a[0]=a[1]=1;
	  String sum = "";
	  for(i=0;i<8;i++)
             a[i+2] = a[i] + a[i+1];
         
	  sum = Integer.toString(a[i+1]);
	  //System.out.println("Fibonacci数列的第十项为:"+sum);
		
	    return sum;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?