I\'m writing a code to determine if every element in my nxn list is the same. i.e. [[0,0],[0,0]]
returns true but [[0,1],[0,0]]
will return false.
To stop your loop you can use break with label. It will stop your loop for sure. Code is written in Java but aproach is the same for the all languages.
public void exitFromTheLoop() {
boolean value = true;
loop_label:for (int i = 0; i < 10; i++) {
if(!value) {
System.out.println("iteration: " + i);
break loop_label;
}
}
}
}