public class BankAccount
{
// instance variables:
private double balance;
/* constructor: it initializes instance variables
it has the same name as the class */
public BankAccount(double a_balance)
{ balance = a_balance;
}
// a second constructor -- it doesn't do anything
public BankAccount()
{  balance = 0;
}
// 'void' below means that the method doesn't return anything
public void deposit(double amount)
{  balance = balance + amount;
}
/**
Withdraws money from the bank account.
@param amount the amount to withdraw
*/
public void withdraw(double amount)
{  balance = balance - amount;
}
// 'double' below means that the method returns a double
/**
Gets the current balance of the bank account.
@return the current balance
*/
public double getBalance()
{
 return balance;
}
public static void main(String[] args)
{ BankAccount harrysChecking = new BankAccount(1000);
double money = harrysChecking.getBalance();
System.out.println("Current balance: " + money);
harrysChecking.deposit(500);
money = harrysChecking.getBalance();
System.out.println("Current balance: " + money);
harrysChecking.withdraw(100);
money = harrysChecking.getBalance();
System.out.println("Current balance: " + money);
}