2 for loops inside a String function

why is this not working?
WhatsApp Image 2021-01-01 at 14.31.10
yea, I know I dont need that boolean finished in the beginning

You can throw a RuntimeException inside your catch () {} block as a workaround:
throw new RuntimeException("192.168." + i + '.' + j);

that isn’t the problem, my problem is that it says the code at the end is unreachable, but thanks

The line return null; is the end of your getServerAdress() function. There’s no way that the code after the return statement can be reached!

Each line of code is like a step in following a recipe. Essentially, what you’ve told the computer to do is to stop doing things, and then do something more. This confuses it. Did you want the function to stop at the return statement? Or did you want it to print “SERVER NOT FOUND” before it stops? You can’t have it both ways! That’s what your error means.

1 Like

oh i didnt think of that, thanks… :laughing: