given:
public void connect() {
try {
connect_to_server();
} catch (ServerUnavailableException ex){
System.out.print("server unavailable");
}
}
I would like to try, and retry, connecting to the server 3 times before giving up.
I could put the entire try/catch in, say, a for
loop, but would this fit with Java's 'Best Practices'. From what I recall on the topic, this would be a misuse of try/catch
statements. Then again, I could be entirely wrong. What do you think?