Advertisement
big_Xplosion

Labels

Jul 7th, 2015
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.54 KB | None | 0 0
  1. public class TestLabels {
  2.  
  3.     public static void main(String[] args) {
  4.         testLabel();
  5.     }
  6.  
  7.     private static void testLabel() {
  8.         int[][] array = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}};
  9.         int toFind  = 2;
  10.  
  11.         searchItem:
  12.             for (int i = 0; i < array.length; i++) {
  13.                 for (int j = 0; j < array[i].length; j++) {
  14.                     System.out.println(String.format("looking at at %s, %s", i, j));
  15.                     if (array[i][j] == toFind) {
  16.                         System.out.println(String.format("found at %s, %s", i, j));
  17.                         break searchItem;
  18.                     }
  19.                 }
  20.             }
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement