Created
September 20, 2024 10:56
-
-
Save vdeemann/1a8069928336216e2bd3e76d44b59373 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... "); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment