44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
package pr2.auffrischung.labeled_break;
|
|
|
|
public class ArraySucher {
|
|
|
|
/**
|
|
* Sucht das erste Element, dass nicht 0 ist.
|
|
*
|
|
* @param array das Array in dem gesucht werden soll
|
|
* {@code true}, wenn ein Element gefunden wird, andernfalls
|
|
* {@code false}.
|
|
*/
|
|
public static void main(String[] array) {
|
|
if (array != null) {
|
|
int[][] narray = new int[array.length][array.length];
|
|
for (int i = 0; i < array.length; i++) {
|
|
for (int j = 0; j < array.length; j++) {
|
|
narray[i][j] = Integer.parseInt(array[i]);
|
|
}
|
|
}
|
|
System.out.println(suche(narray));
|
|
|
|
} else {
|
|
System.out.println("Die Argumentenliste ist leer.");
|
|
|
|
}
|
|
}
|
|
|
|
public static boolean suche(int[][] array) {
|
|
boolean found = false;
|
|
|
|
for (int i = 0; i < array.length; i++) {
|
|
for (int j = 0; j < array.length;) {
|
|
if (array[i][j] != 0) {
|
|
return true;
|
|
} else {
|
|
j++;
|
|
}
|
|
}
|
|
}
|
|
|
|
return found;
|
|
}
|
|
}
|