There is a two-dimensional matrix, elements only 0 and 1; element 1 of the upper and lower left and right elements of 1, can be defined as neighbors; as many neighbors as a group, ask how many groups of the matrix?
If you have idea about this question, I would like to your answer with java language.