21.04.23 Aufgabe 1+2
parent
f10f988806
commit
50086f4274
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue