There are a few ways.
You can break from the inner loop:
for(...) {
while(...) {
...
if(condition) {
break;
}
...
}
}
This will leave the inner loop and the outer loop will continue.
Or you can label the outer loop, and use continue with the name. By default continue and break apply to the innermost loop, but using a name overrides that.
someName: for(...) {
while(...) {
...
if(condition) {
continue someName;
}
...
}
}
Or, you can usually achieve it without break or continue:
for(...) {
boolean done = false;
while(... && !done) {
...
if(condition) {
done = true;
}
}
}
Some people advise avoiding break and continue for the same reason they advise avoiding return in the middle of a routine. Having more than one exit point for a routine is an opportunity for confusing the reader.
However, that can be mitigated by ensuring the routine is short. The problem is where your exit points get lost in long blocks of code.
nameofloop: for(Product: product:ListofProducts){..}and thencontinue nameofloop;whileloop in every case, is that desired? I don't really get the necessarity of awhileloop in this case, anyway... Why do you use it?