class TwoDArray
{
	int i, j; // fields to be used in loops

	// As String is implemented internally as an array of type char
	// beatleStuff is 3 rows by 4 columns
	char[][] beatleStuff =
	{
		// each array is a dimension, and we have three dimensions
		{'h', 'e', 'l', 'p'},
		{'m', 'e', '!', '!'},
		{'y', 'e', 'a', 'h'}
	};

    // This array of Strings is also 3 rows by 4 columns
	String[][] myStringArray =
	{
		{"Hello", "There", "Brown", "Cow"},
		{"Somewhere", "Over", "the", "Rainbow"},
		{"Time", "Is", "On", "My Side"}
	};

	TwoDArray()
	{
		for(i = 0; i < 3; i++) // outer loop for 3 dimensions, 3 rows
		{
			for(j = 0; j < 4; j++) // inner loop for contents of 4 columns
			{
				System.out.print(beatleStuff[i][j]);
			}
			System.out.println("\ni is now: " + i);
		}
		System.out.print("The value of the 3rd row, 1st column is: " + beatleStuff[2][0] + "\n");
	}

	void myMethod()
	{
		for(i = 0; i < 3; i++) // outer loop for 3 dimensions, 3 rows
		{
			for(j = 0; j < 4; j++) // inner loop for contents of 4 columns
			{
				System.out.print(myStringArray[i][j] + " ");
			}
		}
		System.out.print("\nThe value of the 2nd row, 4th column is: " + myStringArray[1][3] + "\n");
	}
}

class TwoDArrayofStringsDemo
{
	public static void main(String[] args)
	{
		// call constructor that prints 2D array of chars
		TwoDArray my2DArray = new TwoDArray();
		// call method that prints 2D array of Strings
		my2DArray.myMethod();

	}
}
