Hi, I am new to Java and I am currently trying to learn how to do multiple row searching in 2D array..
I have an input of character array that starts like this.
private static final char[][] bigSquare = {
{ 'F', 'G', '3', '4'},
{ 'F', 'G', 'C', 'D'},
{ 'E', 'F', 'G', 'H'},
{ 'E', 'F', 'G', 'H'}};
private static final char[][] smallSquare ={
{ 'F', 'G'},
{ 'F', 'G'}};
I am suppose to find the number of occurence of the small squares in the bigSquare in this 2D character array.. but I have no idea how to start,
I currently have this code
//b is the big square, r is the small square, bSize is the width of the big square, rSize is the width of the small square
public static int checkOccurence(char[][] b, char[][] r, int bSize, int rSize) {
int n = 0; //to return
// TODO Search for square occurrences..
for (int i = 0; i < b[0].length; i++) {
for (int j = 0; j < b.length; j++) {
}
System.out.println();
}
return n;
}
The above example should return 2
Can someone point me in the right direction? :(
Edited by: 873045 on Jul 17, 2011 2:01 PM