studentenrollment.java

来自「北京大学出版社的」· Java 代码 · 共 31 行

JAVA
31
字号
package examples.network;
import java.rmi.Naming;
import java.rmi.RMISecurityManager;
/** A server-side program that creates and registers
  * StudentImpl objects with the RMI registry for use
  * by clients
  */
public class StudentEnrollment {
   public static void main( String[] args ) {
      if ( System.getSecurityManager() == null ) {
         System.setSecurityManager(
            new RMISecurityManager() );
      }
      try {
         StudentImpl[] students = {
            new StudentImpl( 1001, "Elaine Jones" ),
            new StudentImpl( 1002, "Patricia Hartswell" ),
            new StudentImpl( 1003, "Darius Smith" ),
            new StudentImpl( 1004, "Mary Bagshaw" ),
            new StudentImpl( 1005, "Henry Miller" )
         };
         for ( int i = 0; i < students.length; i++ ) {
            int id = students[i].getID();
            Naming.rebind( "Student" + id , students[i] );
         }
         System.out.println( "Student objects bound." );
      } catch ( Exception x ) {
         x.printStackTrace();
      }
   }
}

⌨️ 快捷键说明

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