magicnumber.java

来自「Java经典例程 从外国一大学计算机教授出版物下载的代码 经典」· Java 代码 · 共 31 行

JAVA
31
字号
import java.rmi.*;
import java.rmi.server.*;

/*  A remote object      by J M Bishop  Oct 1997
 *  ===============      Java 1.2 August 2000
 *
 *  These objects can be registered on one machine and
 *  accessed via the Internet and rmi protocol from other
 *  machines.  Compilation is a two-step process:
 *    javac MagicNumber.java
 *    rmic MagicNumber
 *  The latter creates skeletons and stubs for the
 *  remote object. To make it accessible on the network:
 *  In Window 1 type:
 *    rmiregistry
 *  The registry will stay running.
 *  Then activate the server and client parts of the system.
 */

class MagicNumber extends UnicastRemoteObject implements Transferable {

  MagicNumber () throws RemoteException {
  }

  public String getNumber () throws RemoteException {
    return "Your magic number is "+ (int) (Math.random()*100);;
  }

}

⌨️ 快捷键说明

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