21.04.23 Aufgabe 1+2

master
j 2023-04-21 15:27:08 +02:00
parent f10f988806
commit 50086f4274
1 changed files with 15 additions and 7 deletions

View File

@ -40,9 +40,13 @@ public class ArrayExperimente
*/
public static boolean istEnthalten(int gesucht, int[] array)
{
// TODO...
// das return steht hier nur, damit der Compiler nicht meckert:
for(int i=0; i<array.length; i++)
{
if (array[i] == gesucht)
{
return true;
}
}
return false;
}
@ -55,10 +59,14 @@ public class ArrayExperimente
*/
public static int indexVon(int gesucht, int[] array)
{
// TODO...
// das return steht hier nur, damit der Compiler nicht meckert:
return -3245646;
for(int i=0; i<array.length; i++)
{
if (array[i] == gesucht)
{
return i;
}
}
return -1;
}