I found this interesting thing you can break a enhance for loop with a break; statment but i want to know if it is possible to break a enhanced For loop from a switch statement inside that statement
For Example
String test = "(2.0+4.0)";
for (char now : test.toCharArray()){
switch (now) {
case '(':
// i want the loop to stop from this point
break;
case ')':
case '/':
case '*':
case '+':
case '-':
}
}
Edited
Found the answer labeled break. but im going Old school
String test = "(2.0+4.0)";
boolean found = false;
for (char now : test.toCharArray()){
switch (now) {
case '(':
// i want the loop to stop from this point
System.out.println(now);
found = true;
continue;
case ')':
case '/':
case '*':
case '+':
case '-':
}
System.out.println("im out of switch");
if(found)break;
}
System.out.println("out of Loop");
}
That Did it
Thanks For All the Answers
continueshould bebreakin your old-school example.