public class BankAccountIf lastAssignedNumber was not static, each instance of BankAccount would have its own value of lastAssignedNumber
{
. . .
private double balance;
private int accountNumber;
private static int lastAssignedNumber = 1000;
}
public BankAccount()
{
// Generates next account number to be assigned
lastAssignedNumber++; // Updates the static field
// Assigns field to account number of this bank account
accountNumber = lastAssignedNumber; // Sets the instance field
}