Auf Thema antworten

wenns wirklich darum geht grundlagen zu lernen, würde ich so eine methode noch selber schreiben...


zb


[code=Java]

public class Test {


   public static void main(String[] args) {

      int[] array = {1, 2, 3, 4, 5, 6, 7, 8};

      System.out.println(inArrayVorahnden(array, 5));

      System.out.println(inArrayVorahnden(array, 9));

   }

  

   public static boolean inArrayVorahnden(int[] array, int wert){

      for(int i = 0 ; i < array.length; i++){

         if(array[i] == wert)

            return true;

      }

      return false;

   }

}

[/code]



Oben