commit
77a3a199d9
|
@ -0,0 +1,22 @@
|
|||
package pr2.auffrischung.grossmacher;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class Grossmacher_Lambda {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// Stream.of(args).forEach(System.out::println);
|
||||
|
||||
Stream.of(args)
|
||||
// hier soll noch eine Split-Funktion eingesetzt werden
|
||||
.map(a -> a.toUpperCase())
|
||||
.forEach(System.out::print);
|
||||
System.out.println();
|
||||
Long counter = Stream.of(args).collect(Collectors.counting());
|
||||
System.out.println("Es wurden " + counter + " Worte als Parameter "
|
||||
+ "übergeben.");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package pr2.auffrischung.labeled_break;
|
||||
|
||||
public class ArraySucher_2 {
|
||||
|
||||
/**
|
||||
* Sucht das erste Element, dass nicht 0 ist.
|
||||
*
|
||||
* @param array das Array in dem gesucht werden soll
|
||||
* @return {@code true}, wenn ein Element gefunden wird,
|
||||
* andernfalls {@code false}.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
int[][] mischung = new int [4] [4];
|
||||
for (int i = 0; i == mischung.length - 1; i++) {
|
||||
for (int j = 0; j == mischung.length - 1; j++) {
|
||||
mischung[i][j] = 0;
|
||||
}
|
||||
}
|
||||
mischung[3][3] = 1;
|
||||
|
||||
|
||||
System.out.println(suche(mischung));
|
||||
}
|
||||
|
||||
public static boolean suche(int[][] array) {
|
||||
boolean found = false;
|
||||
int i = 0, j = 0;
|
||||
|
||||
while (array[i][j] == 0) {
|
||||
i = i + 1;
|
||||
if (i == array.length - 1) {
|
||||
j = j + 1;
|
||||
i = 0;
|
||||
}
|
||||
if (j == array.length - 1) {
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
found = true;
|
||||
return found;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue