transferatob.java

来自「《java事件处理指南》一书的代码,好东西」· Java 代码 · 共 32 行

JAVA
32
字号
class TransferAtoB implements Runnable{   Account acctA, acctB;   int amount;   public TransferAtoB(Account a, Account b, int amt)   {      acctA = a;      acctB = b;      amount = amt;   }/*  The run() method has one of the Account objects invoke the  *//*  transfer() method passing the other Account object and the  *//*  amount of the transaction as arguements.                    */   public void run()   {      acctA.transfer(acctB,amount);      printBalances();   }   public void printBalances()   {      System.out.println(Thread.currentThread().getName()+                         " transaction complete.");      System.out.println(               "   balance of "+acctA.getName()+" = "+acctA.getBalance()+               "   balance of "+acctB.getName()+" = "+acctB.getBalance());   }}

⌨️ 快捷键说明

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