📄 studentenrollment.java
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -