java - Try to reach a special position on 2D Array -


i have problem 2d-arry trying feld [1][4]=true, eclipse dows not go [1][4] position. below output

0 0 (0,0)__ 0 1 (0,1) 1 0 (1,0)__ 1 1 (1,1)__ 1 2 (1,2)__ 1 3 (1,3)__ 1 4 gefunden

i dont know why 1 4 not work if?!? should go in , should errow because [1][5] not reachable...

 package maus;

public class newmausbesser {

public static void rekursivundzwarrichtig (boolean[][]feld2, int n, int m,int arraylänge) { boolean feld[][] = feld2;

system.out.println(n + " " + m);  //und or oder? if((n!=arraylänge-1) && (m !=arraylänge-1)){     //system.out.println(n + " " + m);      if(feld[n][m]==true){         system.out.println("(" + n + "," + m + ")__");         rekursivundzwarrichtig(feld,n,m+1,arraylänge); }     else if (feld[n][m]==false){         system.out.println("(" + n + "," + m + ")");         rekursivundzwarrichtig(feld,n+1,m-1,arraylänge); }     }    else{     //return     system.out.println("gefunden"); } 

}

public static void main(string[] args) { int n = 5; system.out.println("welche maße soll das feld haben (n,n)?"); while(n < 2){ n = keyboard.readint(); if(n < 2){ system.out.println("das feld ist zu klein, bitte wiederholen"); } } boolean feld [][] = new boolean [n][n]; for(int = 0; < n; i++){ for(int p = 0; p < n; p++ ){ feld[i][p] = true;}} feld[0][1]= false; // feld[1][1]= false; rekursivundzwarrichtig(feld,0,0,n); }


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -