I would like to create a String[][] array and fill every element of it with String = " 0". I do not understand why after doing this, when I try to display the array its giving me null's values. Here is code.
import java.util.Vector;
public class hetmani{
private int n;
private String[][] tab;
private Vector wiersz;
private Vector kolumna;
public hetmani(int liczba){
n=liczba;
wiersz = new Vector();
kolumna = new Vector();
tab = new String[n][n];
}
public void wyzeruj(){
for (String[] w : tab){
for (String k : w){
k = " 0";
System.out.print(k);
}
System.out.println();
}
}
public void wyswietl(){
for (String[] i : tab){
for (String j : i){
System.out.print(j);}
System.out.println();}
}
public static void main(String[] args){
hetmani szach = new hetmani(3);
szach.wyzeruj();
szach.wyswietl();
}
}