Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Searching Squares in 2D Array

876048Jul 17 2011 — edited Jul 18 2011
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
This post has been answered by darke on Jul 18 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 15 2011
Added on Jul 17 2011
7 comments
1,223 views