Course Content
Java Basics
Java Basics
Challenge: Building a Server Retry Mechanism
Task
Swipe to show code editor
Your task is to implement a program that attempts to connect to a server up to 5 times. If the connection is successful, the program prints a success message. If it fails after 5 attempts, it prints an error message.
- Start a
do-while
loop that will run up to 5 times. - Increment the retry count in each iteration.
- Check if the current attempt matches the successful attempt number.
- If successful, print a success message and exit the loop.
- After the loop, check if the retry count reached 5.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 4
Challenge: Building a Server Retry Mechanism
Task
Swipe to show code editor
Your task is to implement a program that attempts to connect to a server up to 5 times. If the connection is successful, the program prints a success message. If it fails after 5 attempts, it prints an error message.
- Start a
do-while
loop that will run up to 5 times. - Increment the retry count in each iteration.
- Check if the current attempt matches the successful attempt number.
- If successful, print a success message and exit the loop.
- After the loop, check if the retry count reached 5.
Solution
solution
Switch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?
Thanks for your feedback!
Section 3. Chapter 4
Switch to desktop for real-world practiceContinue from where you are using one of the options below