Skip to content

Instantly share code, notes, and snippets.

@vdeemann
Created September 20, 2024 10:56
Show Gist options
  • Select an option

  • Save vdeemann/1a8069928336216e2bd3e76d44b59373 to your computer and use it in GitHub Desktop.

Select an option

Save vdeemann/1a8069928336216e2bd3e76d44b59373 to your computer and use it in GitHub Desktop.

Revisions

  1. vdeemann created this gist Sep 20, 2024.
    29 changes: 29 additions & 0 deletions EchoTestDriveBonus.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    public class EchoTestDriveBonus {
    public static void main(String[] args) {
    Echo e1 = new Echo();
    Echo e2 = e1;
    int x = 0;
    while (x<4) {
    e1.hello();
    // 0-1 1-2 2-4 3-11
    e1.count = e1.count + 1;
    if (x>0) {
    // 0- 1-3 2-5 3-12
    e2.count = e2.count + 1;
    }
    if (x>1) {
    // 0- 1- 2-10 3-24
    e2.count = e2.count + e1.count;
    }
    x = x + 1;
    }
    System.out.println(e2.count);
    }
    }

    class Echo {
    int count = 0;
    void hello() {
    System.out.println("helloooo... ");
    }
    }