I'm currently on a self learning Java course and am completely stumped at one of my assignments, can anyone give me some pointers please? Bear in mind that I am completely new to Java so I need it to be as simple as.
The question: 3. Create a Java program called TwoDimArray and implement the following:
Create a two dimensional string array anArray[2][2].
Assign values to the 2d array containing any Country and associated colour.
Example:
France Blue
Ireland Green
Output the values of the 2d array using nested for loops.
The code I have come up with that is also not working:
public class TwoDimArray {
public static void main(String[] args) {
char Ireland = 0;
char Green = 1;
char England = 2;
char White = 3;
char firstArray[][] = {{Ireland},{Green}};
char secondArray[][] = {{England},{White}};
System.out.println();
display(firstArray);
System.out.println();
display(secondArray);
}
public static void display(char a[][]) {
for (char row = 0; row < a .length; row++) {
for (char col = 0; col < a [row] .length; col++) {
System.out.print(a[row][col] + " ");
}
System.out.println();
}
}
}
Can anyone give me some pointers? I can't seem to find anything that helps me on the web so thought I'd come here and ask. Thanks in advance.