Java Bank Account Project

Practice Java classes, objects, methods, and encapsulation by building a bank account app.

TutorialsJava Projects › Java Bank Account Project

Project Overview

Practice Java classes, objects, methods, and encapsulation by building a bank account app.

This beginner Java project helps you practice real coding skills with a small program you can run, edit, and improve.

Java Code

class BankAccount {
  private double balance;
  public void deposit(double amount) { balance += amount; }
  public void withdraw(double amount) {
    if (amount <= balance) balance -= amount;
  }
  public double getBalance() { return balance; }
}

public class Main {
  public static void main(String[] args) {
    BankAccount account = new BankAccount();
    account.deposit(100);
    account.withdraw(40);
    System.out.println(account.getBalance());
  }
}

How to Run This Project

  1. Install the Java JDK.
  2. Create a new file. Use the public class name as the file name.
  3. Paste the code into the file.
  4. Compile it using javac FileName.java.
  5. Run it using java FileName.

What You Practice

  • Java syntax
  • Variables and data types
  • Conditions and loops
  • Methods, classes, or objects depending on the project
  • Problem solving

Project Improvements

  • Add input validation.
  • Add better menus and messages.
  • Use classes and objects for better structure.
  • Save data to a file.
  • Convert the project into a GUI app later.

Related Java Lessons

Java Tutorial | Methods | Classes | Objects | Collections