Beginners Java Array Question -


I'm trying to use an array by producing a square of x. The diagonals of the square will be filled with 'X' and empty spaces will be filled with '_'.

Here is the code I got:

  public fixed four [] [] class (int z) {int size = 5; Four [] [] myArr = new four [size] [size]; For (int c = 0; c  = 0; col -) // put X {myArr [r] [col] = 'X'; }} For (int count = 0; count & lt; size; count ++) {if myArr [count] [count]! = 'X') myArr [count] [count] = ''; } Return myArr; }  

This should work - I run it manually on paper and everything should be fine. What can be the problem?

You find the code a bit more with all those IFS and smart loops.
Just fill the array with 'Backdrop' and then make diagonal.

  char [] [] myArr = new char [shape] [size]; For (int i = 0; i  

edit
has been updated to attract two diagonals.


Comments