Hell guys! This is my first post in this forum.The following code on compilation shows :
Exception in thread "main" java.lang.Error: Unresolved compilation problem: Unreachable code
Don't mind me asking, but where do all the nextInt's come from ?
Without any context of what you're trying to do it's really gonna be hard to help.
Also why do you start an infinite loop, just in the hope of breaking out of it?
You also should have a look at The Java Naming Conventions
It's good to be able to use someting, it's better to understand how it works.
Actually the above code is for a deciding a game winner.
Where , t=no of test cases
N=sequence of integers
a=no selected by Bob
b=no selected by Alice
Game will start from Bob and then Alice, alternate turns will occur in which both have to remove multiples of no selected by them one by one . if one is not able to remove multiple of their selected no the other will win.
The outer loop of this pair is an infinite loop. It can only end by using a break, return or throw statement. You do have some break statements, but these are all located inside the inner loop. As a result, these break out of the inner loop. That means the outer loop will still continue forever.
If you want to break out of the outer loop using a break statement in the inner loop, you need to use a labeled break.
Well after one player's turn i have to start iterating the arrayList again from 0 index to check whether any multiple of no selected by the current player is present or not in list. and so on this process will repeat as many times, until winner will not be decided .
To overcome this problem i think let's use the infinite loop and when winner will be decided ,loop will be broke by break.