From ae9204a55b2d8c588ecd9fa03a8db5ff17bb8b70 Mon Sep 17 00:00:00 2001 From: Joyful-coder-x <157543768+Joyful-coder-x@users.noreply.github.com> Date: Mon, 11 Nov 2024 16:30:38 +0800 Subject: [PATCH] Create test --- test | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 0000000..abc0224 --- /dev/null +++ b/test @@ -0,0 +1,26 @@ +// Java - How to Break out of Nested For Loops + +class EscapeNestedLoops { + public static void main(String[] args) { + + for(int x=0; x<8; x++) { + for(int y=1; y<4; y++) { + System.out.println(x + " " + y + " " + x*y); + if(x * y > 5) + break; + } + } + + System.out.println(" "); + + xLoop: + for(int x=0; x<8; x++) { + for(int y=1; y<4; y++) { + System.out.println(x + " " + y + " " + x*y); + if(x * y > 5) + break xLoop; + } + } + + } +}