📄 16t.txt
字号:
// BankClient.java
import java.util.*;
public class BankClient
{
public static void main(String[] args) throws Exception
{
javax.naming.Context context = new javax.naming.InitialContext();
Object ref = context.lookup("accounts/savings");
AccountHome savingsHome =
(AccountHome) javax.rmi.PortableRemoteObject.narrow(ref, AccountHome.class);
ref = context.lookup("accounts/checking");
AccountHome checkingHome =
(AccountHome) javax.rmi.PortableRemoteObject.narrow(ref, AccountHome.class);
Account peter = savingsHome.create("Peter", 200f);
Account paul = checkingHome.create("Paul", 100f);
System.out.println("Peter's balance: " + peter.getBalance());
System.out.println("Paul's balance: " + paul.getBalance());
{
ref = context.lookup("teller");
TellerHome tellerHome =
(TellerHome) javax.rmi.PortableRemoteObject.narrow(ref, TellerHome.class);
Teller teller = tellerHome.create();
System.out.println("Taking from Peter and giving to Paul");
teller.transfer(peter, paul, 100f);
teller.remove();
}
System.out.println("Peter's balance: " + peter.getBalance());
System.out.println("Paul's balance: " + paul.getBalance());
peter.remove();
paul.remove();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -