What is the best way to exit/terminate a while loop in Java?
For example, my code is currently as follows:
while(true){ if(obj == null){
break is what you're looking for:
break
while (true) { if (obj == null) break; }
alternatively, restructure your loop:
while (obj != null) { // do stuff }
or:
do { // do stuff } while (obj != null);