Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: s/static public/public static/g and s/class Cycle()/class Cycle/g

...

Code Block
bgColor#FFcccc
public class Cycle {
  private final int balance;
  private static final Cycle c = new Cycle(); 
  private static final int deposit = (int) (Math.random() * 100); // Random deposit

  public Cycle() {
    balance = deposit - 10; // Subtract processing fee
  }

  public static void main(String[] args) {
    System.out.println("The account balance is: " + c.balance);	
  }
}

The Cycle() class declares a private static final class variable which is initialized to a new instance of the Cycle() class. Static initializers are guaranteed to be invoked once before the first use of a static class member or the first invocation of a constructor.

...

Code Block
bgColor#FFcccc
class A {
    public static public final int a = B.b + 1;
    // ...
}
Code Block
bgColor#FFcccc
class B {
    public static public final int b = A.a + 1;
    // ...
}

...

Code Block
bgColor#ccccff
class A {
    public static public final int a = 2;
    // ...
}

// class B unchanged: b = A.a + 1

...