Skip to content

Instantly share code, notes, and snippets.

@vdeemann
Created September 19, 2024 23:20
Show Gist options
  • Save vdeemann/88623029aa37ccc4f28f457143109179 to your computer and use it in GitHub Desktop.
Save vdeemann/88623029aa37ccc4f28f457143109179 to your computer and use it in GitHub Desktop.
public class EchoTestDrive {
public static void main(String[] args) {
Echo e1 = new Echo();
Echo e2 = new Echo();
int x = 0;
while (x<4) {
e1.hello();
// 0-1 1-2 2-3 3-4
e1.count = e1.count + 1;
if (x>0) {
// 0-0 1-1 2-2 3-6
e2.count = e2.count + 1;
}
if (x>1) {
// 0-0 1-0 2-5 3-10
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... ");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment