Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BreakWithLabelDemo {
- public static void main(String[] args) {
- int[][] arrayOfInts = {
- { 32, 87, 3, 589 },
- { 12, 1076, 2000, 8 },
- { 622, 127, 77, 955 }
- };
- int searchfor = 12; // pesquisa por este numero e não pelo tamanho do vetor...
- int i;
- int j = 0;
- boolean foundIt = false;
- search:
- for (i = 0; i < arrayOfInts.length; i++) {
- for (j = 0; j < arrayOfInts[i].length;
- j++) {
- if (arrayOfInts[i][j] == searchfor) {
- foundIt = true;
- break search;
- }
- }
- }
- if (foundIt) {
- System.out.println("Found " + searchfor + " at " + i + ", " + j);
- } else {
- System.out.println(searchfor + " not in the array");
- }
- String[] names = { "d", "e", "f" };
- for (int h = 0; h < names.length; h++)
- System.out.println(names[h] );
- System.out.print( "tamanho: " + names.length + '\n');
- String[] name = { "Z", "x", "y" };
- for (String nam: name)
- System.out.println(nam);
- }
- }
Add Comment
Please, Sign In to add comment