package encapsulation; public class TestDemo { public static void main(String[] args) { /* BankAccount acct=new BankAccount(); acct.accountID="001"; acct.password="123"; acct.balance=0; System.out.println(acct.balance); if(acct.password=="123"){ System.out.println(acct.balance); } acct.showBalance(); acct.balance+=1000; if(acct.password=="123"){ acct.balance-=10000; } acct.showBalance(); */ BankAccount1 acct1=new BankAccount1("001","123","Fan"); // System.out.println(acct1.balance); acct1.queryBalance("123"); acct1.deposit(200,"fan"); acct1.withdraw("123",100,"Fan"); } } 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/BornFan/archive/2010/04/16/5492979.aspx