criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
public class Main{
Scanner sc=new Scanner(System.in);
int H=sc.nextInt();
int W=sc.nextInt();
String[][] k=new String[H][W];
for(int i=0; i< H; i++){
for(int j=0; j< W; j++){
k[i][j]=sc.next();
}
}
public static void main(String[] args){
int num=0;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(k[i][j]!="."){
dfs(i,j);
num++;
}

}

}

System.out.println(num);

}

public static void dfs(int I,int J){

String p=k[I][J];

k[I][J]=".";

int[] dx={-1,0,0,1};

int[] dy={0,-1,1,0};

for(int i=0;i<4;i++){

if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){

dfs(I+dx[i],J+dy[i]);

}

}

return;

}

}

Compiler output:
Main.java:7: error: illegal start of type
for(int i=0; i< H; i++){
^
Main.java:7: error: > or ',' expected
for(int i=0; i< H; i++){
                 ^
Main.java:7: error: <identifier> expected
for(int i=0; i< H; i++){
                    ^
3 errors
Language: Java

public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int H=sc.nextInt();
int W=sc.nextInt();
String[][] k=new String[H][W];
for(int i=0; i< H; i++){
for(int j=0; j< W; j++){
k[i][j]=sc.next();
}
}
int num=0;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(k[i][j]!="."){
dfs(i,j,H,W,k);
num++;
}
}
}
System.out.println(num);
}
public static void dfs(final int I,final int J,final int H,final int W,String[][] k){
String p=k[I][J];
k[I][J]=".";
int[] dx={-1,0,0,1};
int[] dy={0,-1,1,0};
for(int i=0;i<4;i++){
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
dfs(I+dx[i],J+dy[i],H,W,k);
}
}
return;
}
}

Compiler output:
Main.java:3: error: cannot find symbol
Scanner sc=new Scanner(System.in);
^
  symbol:   class Scanner
  location: class Main
Main.java:3: error: cannot find symbol
Scanner sc=new Scanner(System.in);
               ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
private int H=sc.nextInt();
private int W=sc.nextInt();
private String[][] k=new String[H][W];
for(int i=0; i< H; i++){
for(int j=0; j< W; j++){
k[i][j]=sc.next();
}
}
int num=0;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(k[i][j]!="."){
dfs(i,j);
num++;
}
}
}
System.out.println(num);
}
void dfs(int I,int J){
String p=k[I][J];
k[I][J]=".";
int[] dx={-1,0,0,1};
int[] dy={0,-1,1,0};
for(int i=0;i<4;i++){
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
dfs(I+dx[i],J+dy[i]);
}
}
return;
}
}

Compiler output:
Main.java:5: error: illegal start of expression
private int H=sc.nextInt();
^
Main.java:8: error: illegal start of type
for(int i=0; i< H; i++){
^
Main.java:8: error: > or ',' expected
for(int i=0; i< H; i++){
                 ^
Main.java:8: error: <identifier> expected
for(int i=0; i< H; i++){
                    ^
Main.java:14: error: illegal start of type
for(int i=0; i<H; i++){
^
Main.java:14: error: > or ',' expected
for(int i=0; i<H; i++){
                ^
Main.java:14: error: <identifier> expected
for(int i=0; i<H; i++){
                   ^
Main.java:22: error: <identifier> expected
System.out.println(num);
                  ^
Main.java:22: error: <identifier> expected
System.out.println(num);
                      ^
Main.java:24: error: unnamed classes are a preview feature and are disabled by default.
void dfs(int I,int J){
^
  (use --enable-preview to enable unnamed classes)
Main.java:36: error: class, interface, enum, or record expected
}
^
11 errors
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int H=sc.nextInt();
int W=sc.nextInt();
String[][] k=new String[H][W];
for(int i=0; i< H; i++){
for(int j=0; j< W; j++){
k[i][j]=sc.next();
}
}
int num=0;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(k[i][j]!="."){
dfs(i,j);
num++;
}
}
}
System.out.println(num);
}
void dfs(int I,int J){
String p=k[I][J];
k[I][J]=".";
int[] dx={-1,0,0,1};
int[] dy={0,-1,1,0};
for(int i=0;i<4;i++){
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
dfs(I+dx[i],J+dy[i]);
}
}
return;
}
}

Compiler output:
Main.java:17: error: non-static method dfs(int,int) cannot be referenced from a static context
dfs(i,j);
^
Main.java:25: error: cannot find symbol
String p=k[I][J];
         ^
  symbol:   variable k
  location: class Main
Main.java:26: error: cannot find symbol
k[I][J]=".";
^
  symbol:   variable k
  location: class Main
Main.java:30: error: cannot find symbol
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
      ^
  symbol:   variable k
  location: class Main
Main.java:30: error: cannot find symbol
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
                                               ^
  symbol:   variable H
  location: class Main
Main.java:30: error: cannot find symbol
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
                                                                      ^
  symbol:   variable W
  location: class Main
6 errors
Language: Java

import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int H=sc.nextInt();
int W=sc.nextInt();
String[][] k=new String[H][W];
for(int i=0; i< H; i++){
for(int j=0; j< W; j++){
k[i][j]=sc.next();
}
}
int num=0;
for(int i=0; i<H; i++){
for(int j=0; j<W; j++){
if(k[i][j]!="."){
dfs(i,j,H,W,k);
num++;
}
}
}
System.out.println(num);
}
void dfs(final int I,final int J,final int H,final int W,String[][] k){
String p=k[I][J];
k[I][J]=".";
int[] dx={-1,0,0,1};
int[] dy={0,-1,1,0};
for(int i=0;i<4;i++){
if(p==k[I+dx[i]][J+dy[i]]&&I+dx[i]>=0&&I+dx[i]<H&&J+dy[i]>=0&&J+dy[i]<W){
dfs(I+dx[i],J+dy[i],H,W,k);
}
}
return;
}
}

Compiler output:
Main.java:17: error: non-static method dfs(int,int,int,int,String[][]) cannot be referenced from a static context
dfs(i,j,H,W,k);
^
1 error
Language: Java

import java.util.Scanner; 
 public class Main{
 public static void main(String[] args){
 Scanner sc=new Scanner(System.in);
 int H=sc.nextInt();
 int W=sc.nextInt();
 String[][] k=new String[H][W];
 for(int i=0; i< H; i++){
 for(int j=0; j< W; j++){
 k[i][j]=sc.next();
 }
 }
 int num=0;
 for(int i=0; i<H; i++){
 for(int j=0; j<W; j++){
 if(k[i][j]!="."){
 dfs(i,j,H,W,k);
 num++;
 }
 }
 }
 System.out.println(num);
 }
 public static void dfs(int I,int J,final int H,final int W,String[][] k){
 String p=k[I][J];
 k[I][J]=".";
 int[] dx={-1,0,0,1};
 int[] dy={0,-1,1,0};
 for(int t=0;t<4;t++){
 if(p==k[I+dx[t]][J+dy[t]]&&I+dx[i]>=0&&I+dx[t]<H&&J+dy[t]>=0&&J+dy[t]<W){
 dfs(I+dx[t],J+dy[t],H,W,k);
 }
 }
 return;
 }
 }

Compiler output:
Main.java:30: error: cannot find symbol
 if(p==k[I+dx[t]][J+dy[t]]&&I+dx[i]>=0&&I+dx[t]<H&&J+dy[t]>=0&&J+dy[t]<W){
                                 ^
  symbol:   variable i
  location: class Main
1 error
Language: Java

import java.util.Scanner; 
 public class Main{
 public static void main(String[] args){
 Scanner sc=new Scanner(System.in);
 int H=sc.nextInt();
 int W=sc.nextInt();
 String[][] k=new String[H][W];
 for(int i=0; i< H; i++){
String s=sc.next();
 for(int j=0; j< W; j++){
 k[i][j]=s.charAt(j);
 }
 }
 int num=0;
 for(int i=0; i<H; i++){
 for(int j=0; j<W; j++){
 if(k[i][j]!="."){
 dfs(i,j,H,W,k);
 num++;
 }
 }
 }
 System.out.println(num);
 }
 public static void dfs(int I,int J,final int H,final int W,String[][] k){
 String p=k[I][J];
 k[I][J]=".";
 int[] dx={-1,0,0,1};
 int[] dy={0,-1,1,0};
 for(int t=0;t<4;t++){
 if(p==k[I+dx[t]][J+dy[t]]&&I+dx[t]>=0&&I+dx[t]<H&&J+dy[t]>=0&&J+dy[t]<W){
 dfs(I+dx[t],J+dy[t],H,W,k);
 }
 }
 return;
 }
 }

Compiler output:
Main.java:11: error: incompatible types: char cannot be converted to String
 k[i][j]=s.charAt(j);
                 ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.Deque;
import java.util.ArrayDeque;

class Main{
public static void main(String[] args) throws IOExeption{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] fruit=new char[h][w];
for(int i=0;i<h;i++){
fruit[i]=br.readLine().toCharArray();
}
Deque<Point> que=new ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(fruit[m][n]!=','){
ans++;
Point p=new Point(n,m);
que.offerLast(p);
while(que.peekFirst()!=null){
p=que.pollFirst();
int x=p.x;
int y=p.y;
char rem=fruit[y][x];
fruit[x][y]=',';
int[] dx={-1,0,1,0};
int[] dy={0,-1,0,1};
for(int i=0;i<dx.length;i++){
int nx=x+dx[i];
int ny=y+dy[i];
if(fruit[ny][nx]==rem&&fruit[ny][nx]!=','&&nx>=0&&nx<w&&ny>=0&&ny<h){
Point np=new Point();
np.x=nx;
np.y=ny;
que.offerFirst(np);
}
}
}
}
}
}
System.out.println(ans);
}
}
}

Compiler output:
Main.java:9: error: cannot find symbol
public static void main(String[] args) throws IOExeption{
                                              ^
  symbol:   class IOExeption
  location: class Main
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;

class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] fruit=new char[h][w];
for(int i=0;i<h;i++){
fruit[i]=br.readLine().toCharArray();
}
Queue <Point> fifo  =new  LinkedList<Point>();
            int ans=0;
            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
            if(map[m][n]!='.'){
                ans++;
                Point p = new Point(n,m);
                fifo.add(p);
            while(fifo.peek()!=null){
                p=fifo.poll();
                int x=p.x;
                int y=p.y;
                char crop = map[y][x];
                map[y][x]='.';
                int [] dx ={0,1,0,-1};
                int [] dy ={1,0,-1,0};
                 
                for(int i=0;i<4;i++){
                    int nx =x+dx[i];
                    int ny =y+dy[i];
                    if(0<=nx&&nx<w&&0<=ny&&ny<h&&map[ny][nx]==crop&&map[ny][nx]!='.'){
                        Point np = new Point();
                        np.x=nx;
                        np.y=ny;
                        fifo.add(np);
                         
                    }
                }
            }
            }
                }
            }System.out.println(ans);
           }
        }
}

Compiler output:
Main.java:23: error: cannot find symbol
            if(map[m][n]!='.'){
               ^
  symbol:   variable map
  location: class Main
Main.java:31: error: cannot find symbol
                char crop = map[y][x];
                            ^
  symbol:   variable map
  location: class Main
Main.java:32: error: cannot find symbol
                map[y][x]='.';
                ^
  symbol:   variable map
  location: class Main
Main.java:39: error: cannot find symbol
                    if(0<=nx&&nx<w&&0<=ny&&ny<h&&map[ny][nx]==crop&&map[ny][nx]!='.'){
                                                 ^
  symbol:   variable map
  location: class Main
Main.java:39: error: cannot find symbol
                    if(0<=nx&&nx<w&&0<=ny&&ny<h&&map[ny][nx]==crop&&map[ny][nx]!='.'){
                                                                    ^
  symbol:   variable map
  location: class Main
5 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
 
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> fifo  =new  Arraydeque<Point>();
            int ans=0;
            for(int m=0;m<h;m++){
                for(int n=0;n<w;n++){
            if(map[m][n]!='.'){
                ans++;
                Point p = new Point(n,m);
                fifo.addLast(p);
            while(fifo.peekFirst()!=null){
                p=fifo.pollFirst();
                int x=p.x;
                int y=p.y;
                char crop = map[y][x];
                map[y][x]='.';
                int [] dx ={0,1,0,-1};
                int [] dy ={1,0,-1,0};
                  
                for(int i=0;i<4;i++){
                    int nx =x+dx[i];
                    int ny =y+dy[i];
                    if(0<=nx&&nx<w&&0<=ny&&ny<h&&map[ny][nx]==crop&&map[ny][nx]!='.'){
                        Point np = new Point();
                        np.x=nx;
                        np.y=ny;
                     fifo.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Compiler output:
Main.java:19: error: cannot find symbol
Deque <Point> fifo  =new  Arraydeque<Point>();
                          ^
  symbol:   class Arraydeque
  location: class Main
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
   
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> que=new  ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(map[m][n]!='.'){
ans++;
Point p = new Point(n,m);
fifo.addLast(p);
while(fifo.peekFirst()!=null){
p=fifo.pollFirst();
int x=p.x;
int y=p.y;
char crop = map[y][x];
map[y][x]='.';
int [] dx ={0,1,0,-1};
int [] dy ={1,0,-1,0};                   
for(int i=0;i<4;i++){
int nx =x+dx[i];
int ny =y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]!='.'&&map[ny][nx]==crop){
Point np = new Point();
np.x=nx;
np.y=ny;
fifo.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Compiler output:
Main.java:26: error: cannot find symbol
fifo.addLast(p);
^
  symbol:   variable fifo
  location: class Main
Main.java:27: error: cannot find symbol
while(fifo.peekFirst()!=null){
      ^
  symbol:   variable fifo
  location: class Main
Main.java:28: error: cannot find symbol
p=fifo.pollFirst();
  ^
  symbol:   variable fifo
  location: class Main
Main.java:42: error: cannot find symbol
fifo.addLast(np);                       
^
  symbol:   variable fifo
  location: class Main
4 errors
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.awt.Point;
import java.util.*;
   
class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String str;
while(!(str=br.readLine()).equals("0 0")){
String[] value=str.split(" ");
int h=Integer.parseInt(value[0]);
int w=Integer.parseInt(value[1]);
char[][] map=new char[h][w];
for(int i=0;i<h;i++){
map[i]=br.readLine().toCharArray();
}
Deque <Point> que=new  ArrayDeque<Point>();
int ans=0;
for(int m=0;m<h;m++){
for(int n=0;n<w;n++){
if(map[m][n]!='.'){
ans++;
Point p = new Point(n,m);
fifo.addLast(p);
while(que.peekFirst()!=null){
p=que.pollFirst();
int x=p.x;
int y=p.y;
char crop = map[y][x];
map[y][x]='.';
int [] dx ={0,1,0,-1};
int [] dy ={1,0,-1,0};                   
for(int i=0;i<4;i++){
int nx =x+dx[i];
int ny =y+dy[i];
if(nx>=0&&nx<w&&ny>=0&&ny<h&&map[ny][nx]!='.'&&map[ny][nx]==crop){
Point np = new Point();
np.x=nx;
np.y=ny;
que.addLast(np);                       
}
}
}
}
}
}System.out.println(ans);
}
}
}

Compiler output:
Main.java:26: error: cannot find symbol
fifo.addLast(p);
^
  symbol:   variable fifo
  location: class Main
1 error
Language: Java

import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main{
	static FastReader in = new FastReader();
	static int[][] separate;
	static char[][] land;
	static int h;
	static int w;

	public static void main(String[] args) {
		h = in.nextInt();
		w = in.nextInt();
		land = in.nextCharArray2d(h, w);
		int zero = in.nextInt();
		zero = in.nextInt();

		separate = new int[h][w];
		int owner = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (separate[i][j] > 0) continue;
				dfs(i, j, land[i][j], ++owner);
			}
		}
		printExit(owner);
	}

	private static void dfs(int i, int j, char type, int owner) {
		if (land[i][j] != type || separate[i][j] > 0) return;
		separate[i][j] = owner;
		if (j > 0) dfs(i, j - 1, type, owner);
		if (i > 0) dfs(i - 1, j, type, owner);
		if (j < w - 1) dfs(i, j + 1, type, owner);
		if (i < h - 1) dfs(i + 1, j, type, owner);
	}

	static void printExit(Object msg) {
		System.out.println(msg);
		System.exit(0);
	}
}

class FastReader{
	private InputStream in = System.in;
	private byte[] buf = new byte[1024];
	private int charNum;
	private int charLen;
	private StringBuilder sb = new StringBuilder();

	public int read() {
		if (charLen == -1) throw new InputMismatchException();
		if (charNum >= charLen) {
			charNum = 0;
			try {
				charLen = in.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (charLen <= 0) return -1;
		}
		return buf[charNum++];
	}

	public String next() {
		int c = read();
		while (isWhitespace(c)) {
			c = read();
		}
		sb.setLength(0);
		do {
			sb.appendCodePoint(c);
			c = read();
		} while (!isWhitespace(c));
		return sb.toString();
	}

	public char[] nextCharArray() {
		return next().toCharArray();
	}

	public char[][] nextCharArray2d(int lines, int rows) {
		char[][] array = new char[lines][rows];
		for (int i = 0; i < lines; i++)
			array[i] = nextCharArray();
		return array;
	}

	public boolean isWhitespace(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}

Compiler output:
Main.java:13: error: cannot find symbol
		h = in.nextInt();
		      ^
  symbol:   method nextInt()
  location: variable in of type FastReader
Main.java:14: error: cannot find symbol
		w = in.nextInt();
		      ^
  symbol:   method nextInt()
  location: variable in of type FastReader
Main.java:16: error: cannot find symbol
		int zero = in.nextInt();
		             ^
  symbol:   method nextInt()
  location: variable in of type FastReader
Main.java:17: error: cannot find symbol
		zero = in.nextInt();
		         ^
  symbol:   method nextInt()
  location: variable in of type FastReader
4 errors
Language: Java

import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/07.
 */
public class AOJ0118 {

    static int h, w;
    static int[] dx = {0, 1,  0, -1};
    static int[] dy = {1, 0, -1,  0};
    static char[][] grid = new char[105][105];
    static int ans = 0;

    public static void dfs(int i, int j , char c) {
        // stopping condition
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        if(grid[i][j] != c) return;

        // marking where already visit
        grid[i][j] = '.';

        // recursion
        for(int k = 0; k < 4; k++) dfs(i + dx[k], j + dy[k], c);
    }

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);
        h = sc.nextInt();
        w = sc.nextInt();
        for(int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }

        // dfs
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(grid[i][j] != '.') {
                    ans++;
                    dfs(i, j, grid[i][j]);
                }

            }
        }

        System.out.println(ans);
    }

}

Compiler output:
Main.java:6: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/07.
 */
public class AOJ0118 {

    static Scanner sc = new Scanner(System.in);
    static int h, w;
    static int[] dx = {0, 1,  0, -1};
    static int[] dy = {1, 0, -1,  0};
    static char[][] grid = new char[105][105];

    public static void dfs(int i, int j , char c) {
        // stopping condition
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        if(grid[i][j] != c) return;

        // marking where already visit
        grid[i][j] = '.';

        // recursion
        for(int k = 0; k < 4; k++) dfs(i + dx[k], j + dy[k], c);
        return;
    }

    public static void solve() {
        int ans = 0;

        // input
        for(int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }

        // dfs
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(grid[i][j] != '.') {
                    ans++;
                    dfs(i, j, grid[i][j]);
                }

            }
        }

        System.out.println(ans);
        return;
    }

    public static void main(String[] args) {
        while(true) {
            h = sc.nextInt();
            w = sc.nextInt();
            if(h == 0 && w == 0) break;
            solve();
        }
        return;
    }

}

Compiler output:
Main.java:6: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/07.
 */
public class AOJ0118 {

    static Scanner sc = new Scanner(System.in);
    static int h, w;
    static int[] dx = {0, 1,  0, -1};
    static int[] dy = {1, 0, -1,  0};
    static char[][] grid = new char[105][105];

    public static boolean read() {
        h = sc.nextInt();
        w = sc.nextInt();
        if(h == 0 && w == 0) return false;

        for(int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }
        return true;
    }

    public static void dfs(int i, int j , char c) {
        // stopping condition
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        if(grid[i][j] != c) return;

        // marking where already visit
        grid[i][j] = '.';

        // recursion
        for(int k = 0; k < 4; k++) dfs(i + dx[k], j + dy[k], c);
        return;
    }

    public static void solve() {
        int ans = 0;

        // dfs
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(grid[i][j] != '.') {
                    ans++;
                    dfs(i, j, grid[i][j]);
                }

            }
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        while(read()) {
            solve();
        }
    }

}

Compiler output:
Main.java:6: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.util.Scanner;

/**
 * Created by sotetsuk on 2015/07/07.
 */
public class Main{

    static Scanner sc = new Scanner(System.in);
    static int h, w;
    static int[] dx = {0, 1,  0, -1};
    static int[] dy = {1, 0, -1,  0};
    static char[][] grid = new char[105][105];

    public static boolean read() {
        h = sc.nextInt();
        w = sc.nextInt();
        if(h == 0 && w == 0) return false;

        for(int i = 0; i < h; i++) {
            grid[i] = sc.next().toCharArray();
        }
        return true;
    }

    public static void dfs(int i, int j , char c) {
        return;

        // stopping condition
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        if(grid[i][j] == '.') return;

        // marking
        grid[i][j] = '.';

        // recursion
        for(int k = 0; k < 4; k++) dfs(i + dx[k], j + dy[k], c);
    }

    public static void solve() {
        int ans = 0;

        // dfs
        for(int i = 0; i < h; i++) {
            for(int j = 0; j < w; j++) {
                if(grid[i][j] != '.') {
                    ans++;
                    dfs(i, j, grid[i][j]);
                }

            }
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        while(read()) solve();
    }

}

Compiler output:
Main.java:29: error: unreachable statement
        if(i < 0 || i >= h || j < 0 || j >= w) return;
        ^
1 error
Language: Java

package aoj0118;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * author: Acrafter
 * date: 2017/1/11
 * time: 22:03
 */
public class aoj0118 {
    private static char[][] farm = new char[100][100];
    private static int[] dx = {1, -1, 0, 0}, dy = {0, 0, 1, -1};
    private static int result = 0;
    private static int H, W;
    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String[] HW = input.readLine().split(" ");
        H = Integer.parseInt(HW[0]); W = Integer.parseInt(HW[1]);
        for (int y = 0; y < H; y++) {
            char[] line = input.readLine().toCharArray();
            farm[y] = line;
        }
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                if(farm[y][x]!='W'){
                    dfs(y, x, farm[y][x]);
                    result += 1;
                }
            }
        }
        System.out.println(result);
        result = 0;
    }

    public static void dfs(int y, int x, char flag){
        farm[y][x] = 'W'; // ?????°??°???
        for(int i=0; i<4; i++){
            int ny = y + dy[i], nx = x + dx[i];
            if (0<=ny && ny<H && 0<=nx && nx<W && farm[ny][nx]==flag) {
                dfs(ny, nx, flag);
            }
        }
    }
}

Compiler output:
Main.java:12: error: class aoj0118 is public, should be declared in a file named aoj0118.java
public class aoj0118 {
       ^
1 error
Language: Java

import java.util.*;

public class AOJ0118 {
    private static char[][] room;
    private static boolean[][] roomVisited;
    private static int count;
    private static int[][] directions = {{1,0}, {0,1}, {0,-1}, {-1,0}};


    public static void main(String[] args) {
        test();
        Scanner sc = new Scanner(System.in);
        int w, h;
        String lineOfInput;

        while(true) {
            w = sc.nextInt();
            h = sc.nextInt();
            if (w == 0 && h == 0) break;

            room = new char[h][w];
            roomVisited = new boolean[h][w];
            for (boolean[] row: roomVisited)
                Arrays.fill(row, false);
            count = 0;

            sc.nextLine(); // for empty line
            for (int i = 0; i < h; i++) {
                lineOfInput = sc.nextLine();
                for (int j = 0; j < w; j++) {
                    room[i][j] = lineOfInput.charAt(j);
                }
            }

            for (int y = 0; y < h; y++) {
                for (int x = 0; x < w; x++) {
                    if (!roomVisited[y][x]) {
                        roomVisited[y][x] = true;
                        dfs(x, y);
                        count++;
                    }
                }
            }

            System.out.println(count);
        }
    }

    private static void dfs(int x, int y) {
        int nx, ny;
        for (int[] direction: directions) {
            nx = x + direction[0];
            ny = y + direction[1];
            if (nx >= 0 && ny >= 0 && nx < room[0].length && ny < room.length) {
                if (!roomVisited[ny][nx] && room[y][x] == room[ny][nx]) {
                    roomVisited[ny][nx] = true;
                    dfs(nx, ny);
                }
            }
        }
    }

    private static int calc(int x) {

        return x;
    }

    private static void test() {
        assert calc(0) == 0;
    }
}

Compiler output:
Main.java:3: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.util.*;

public class AOJ0118 {
    private static char[][] room;
    private static boolean[][] roomVisited;
    private static int count;
    private static int[][] directions = {{1,0}, {0,1}, {0,-1}, {-1,0}};


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w, h;
        String lineOfInput;

        while(true) {
            w = sc.nextInt();
            h = sc.nextInt();

            if (w == 0 && h == 0) break;

            room = new char[h][w];
            roomVisited = new boolean[h][w];
            for (boolean[] row: roomVisited)
                Arrays.fill(row, false);
            count = 0;

            sc.nextLine(); // for empty line
            for (int i = 0; i < h; i++) {
                lineOfInput = sc.nextLine();
                for (int j = 0; j < w; j++) {
                    room[i][j] = lineOfInput.charAt(j);
                }
            }

//            for (int y = 0; y < h; y++) {
//                for (int x = 0; x < w; x++) {
//                    if (!roomVisited[y][x]) {
//                        roomVisited[y][x] = true;
//                        dfs(x, y);
//                        count++;
//                    }
//                }
//            }

            System.out.println(count);
        }
    }

    private static void dfs(int x, int y) {
        int nx, ny;
        for (int[] direction: directions) {
            nx = x + direction[0];
            ny = y + direction[1];
            if (nx >= 0 && ny >= 0 && nx < room[0].length && ny < room.length) {
                if (!roomVisited[ny][nx] && room[y][x] == room[ny][nx]) {
                    roomVisited[ny][nx] = true;
                    dfs(nx, ny);
                }
            }
        }
    }
}

Compiler output:
Main.java:3: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.util.*;

public class AOJ0118 {
    private static char[][] room;
    private static boolean[][] roomVisited;
    private static int count;
    private static int[][] directions = {{1,0}, {0,1}, {0,-1}, {-1,0}};


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w, h;
        String lineOfInput;

        while(true) {
            w = sc.nextInt();
            h = sc.nextInt();

            if (w == 0 && h == 0) break;

            room = new char[h][w];
            roomVisited = new boolean[h][w];
            for (boolean[] row: roomVisited)
                Arrays.fill(row, false);
            count = 0;

            sc.nextLine(); // for empty line
//            for (int i = 0; i < h; i++) {
//                lineOfInput = sc.nextLine();
//                for (int j = 0; j < w; j++) {
//                    room[i][j] = lineOfInput.charAt(j);
//                }
//            }

//            for (int y = 0; y < h; y++) {
//                for (int x = 0; x < w; x++) {
//                    if (!roomVisited[y][x]) {
//                        roomVisited[y][x] = true;
//                        dfs(x, y);
//                        count++;
//                    }
//                }
//            }

            System.out.println(count);
        }
    }

    private static void dfs(int x, int y) {
        int nx, ny;
        for (int[] direction: directions) {
            nx = x + direction[0];
            ny = y + direction[1];
            if (nx >= 0 && ny >= 0 && nx < room[0].length && ny < room.length) {
                if (!roomVisited[ny][nx] && room[y][x] == room[ny][nx]) {
                    roomVisited[ny][nx] = true;
                    dfs(nx, ny);
                }
            }
        }
    }
}

Compiler output:
Main.java:3: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118 {
       ^
1 error
Language: Java

import java.io.*;
public class AOJ0118{
	public static void main(String args[]){
			AOJ0118 a = new AOJ0118();
	}
	
	public AOJ0118(){
		setMap();
		//showMap();
		run();
	}

	String[][] map;
	
	private void showMap(){
		for(int i = 0; i < map.length; i++){
			for(int j = 0; j < map[0].length; j++){
				System.out.print(map[i][j]);
			}
			System.out.println("");
		}
		System.out.println("");
	}
	
	private void setMap(){
		try{
			BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
			int H = -1;			
			int W = -1;
			int expected = 0;
			
			String line = "";
			int tempH = 0;
			while(!(line = stdReader.readLine()).equals("0 0")) {
				if(W==-1){
					H = Integer.valueOf(line.split(" ")[0]);
					W = Integer.valueOf(line.split(" ")[1]);
					map = new String[H][W];
				}else if(!line.equals("0 0")){
					setLine(tempH, line);
					tempH += 1;
				}
			}
			stdReader.close();
			System.out.println("\nPROGRAM END");
		}catch(Exception e){
		  e.getStackTrace();
		  System.exit(-1); // ????????°???????????????
		}
	}
	private void run(){
		int person = 0;
		int[] point;
		while((point = getPointOfNotSearcherArea()) != null){
			search(point);
			person++;
		}
		System.out.println(person);
	}
	
	private void search(int[] point){
		int x = point[0];
		int y = point[1];
		String temp = map[x][y];
		map[x][y] = "_";
		for(int diff = -1;  diff<=1; diff++){
			if(x+diff>=0 && x+diff<map.length){
				if(map[x+diff][y].equals(temp)&&!map[x+diff][y].equals("_")){
					int[] neoPoint = {x+diff, y};
					search(neoPoint);
				}
			}
			if(y+diff>=0 && y+diff<map.length){
				if(map[x][y+diff].equals(temp)&&!map[x][y+diff].equals("_")){
					int[] neoPoint = {x, y+diff};
					search(neoPoint);
				}
			}
		}
		//showMap();
		//System.out.println("");
	}

	private int[] getPointOfNotSearcherArea(){
		for(int i = 0; i < map.length; i++){
			for(int j = 0; j < map[0].length; j++){
				if(!map[i][j].equals("_")){
					int point[] = {i,j};
					return point;
				}
			}
		}
		return null;
	}
		
	private void setLine(int tempH, String input){
		for(int i = 0; i < map[tempH].length; i++){
			String entity = input.substring(i,i+1);
			map[tempH][i] = entity;
		}
	}
}

	

Compiler output:
Main.java:2: error: class AOJ0118 is public, should be declared in a file named AOJ0118.java
public class AOJ0118{
       ^
1 error
Language: Java

import java.io.*;
public class Main{
	public static void main(String args[]){
			Main a = new AOJ0118();
	}
	
	public AOJ0118(){
		setMap();
		//showMap();
		run();
	}

	String[][] map;
	
	private void showMap(){
		for(int i = 0; i < map.length; i++){
			for(int j = 0; j < map[0].length; j++){
				System.out.print(map[i][j]);
			}
			System.out.println("");
		}
		System.out.println("");
	}
	
	private void setMap(){
		try{
			BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
			int H = -1;			
			int W = -1;
			int expected = 0;
			
			String line = "";
			int tempH = 0;
			while(!(line = stdReader.readLine()).equals("0 0")) {
				if(W==-1){
					H = Integer.valueOf(line.split(" ")[0]);
					W = Integer.valueOf(line.split(" ")[1]);
					map = new String[H][W];
				}else if(!line.equals("0 0")){
					setLine(tempH, line);
					tempH += 1;
				}
			}
			stdReader.close();
			System.out.println("\nPROGRAM END");
		}catch(Exception e){
		  e.getStackTrace();
		  System.exit(-1); // ????????°???????????????
		}
	}
	private void run(){
		int person = 0;
		int[] point;
		while((point = getPointOfNotSearcherArea()) != null){
			search(point);
			person++;
		}
		System.out.println(person);
	}
	
	private void search(int[] point){
		int x = point[0];
		int y = point[1];
		String temp = map[x][y];
		map[x][y] = "_";
		for(int diff = -1;  diff<=1; diff++){
			if(x+diff>=0 && x+diff<map.length){
				if(map[x+diff][y].equals(temp)&&!map[x+diff][y].equals("_")){
					int[] neoPoint = {x+diff, y};
					search(neoPoint);
				}
			}
			if(y+diff>=0 && y+diff<map.length){
				if(map[x][y+diff].equals(temp)&&!map[x][y+diff].equals("_")){
					int[] neoPoint = {x, y+diff};
					search(neoPoint);
				}
			}
		}
		//showMap();
		//System.out.println("");
	}

	private int[] getPointOfNotSearcherArea(){
		for(int i = 0; i < map.length; i++){
			for(int j = 0; j < map[0].length; j++){
				if(!map[i][j].equals("_")){
					int point[] = {i,j};
					return point;
				}
			}
		}
		return null;
	}
		
	private void setLine(int tempH, String input){
		for(int i = 0; i < map[tempH].length; i++){
			String entity = input.substring(i,i+1);
			map[tempH][i] = entity;
		}
	}
}

	

Compiler output:
Main.java:7: error: invalid method declaration; return type required
	public AOJ0118(){
	       ^
1 error
Language: Java

import java.io.*;
public class Main{
    public static void main(String args[]){
            Main a = new Main();
    }
    
    public Main(){
        setMap();
        //showMap();
        run();
    }

    String[][] map;
    
    private void showMap(){
        for(int i = 0; i < map.length; i++){
            for(int j = 0; j < map[0].length; j++){
                System.out.print(map[i][j]);
            }
            System.out.println("");
        }
        System.out.println("");
    }
    
    private void setMap(){
        try{
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            int H = -1;            
            int W = -1;
            int expected = 0;
            
            String line = "";
            int tempH = 0;
            while(!(line = stdReader.readLine())!=null) {
                if(W==-1){
                    H = Integer.valueOf(line.split(" ")[0]);
                    W = Integer.valueOf(line.split(" ")[1]);
                    map = new String[H][W];
                }else if(!line.equals("0 0")){
                    setLine(tempH, line);
                    tempH += 1;
                }
            }
            stdReader.close();
        }catch(Exception e){
			e.getStackTrace();
        }
    }
    private void run(){
        int person = 0;
        int[] point;
        while((point = getPointOfNotSearcherArea()) != null){
            search(point);
            person++;
        }
        System.out.println(person);
    }
    
    private void search(int[] point){
        int x = point[0];
        int y = point[1];
        String temp = map[x][y];
        map[x][y] = "_";
        for(int diff = -1;  diff<=1; diff++){
            if(x+diff>=0 && x+diff<map.length){
                if(map[x+diff][y].equals(temp)&&!map[x+diff][y].equals("_")){
                    int[] neoPoint = {x+diff, y};
                    search(neoPoint);
                }
            }
            if(y+diff>=0 && y+diff<map.length){
                if(map[x][y+diff].equals(temp)&&!map[x][y+diff].equals("_")){
                    int[] neoPoint = {x, y+diff};
                    search(neoPoint);
                }
            }
        }
        //showMap();
        //System.out.println("");
    }

    private int[] getPointOfNotSearcherArea(){
        for(int i = 0; i < map.length; i++){
            for(int j = 0; j < map[0].length; j++){
                if(!map[i][j].equals("_")){
                    int point[] = {i,j};
                    return point;
                }
            }
        }
        return null;
    }
        
    private void setLine(int tempH, String input){
        for(int i = 0; i < map[tempH].length; i++){
            String entity = input.substring(i,i+1);
            map[tempH][i] = entity;
        }
    }
}

    

Compiler output:
Main.java:34: error: bad operand type String for unary operator '!'
            while(!(line = stdReader.readLine())!=null) {
                  ^
1 error
Language: Java

import java.io.*;
public class Main{
    public static void main(String args[]){
		Main a = new Main();
		a.run();
    }

    String[][] map;
    
    private void showMap(){
        for(int i = 0; i < map.length; i++){
            for(int j = 0; j < map[0].length; j++){
                System.out.print(map[i][j]);
            }
            System.out.println("");
        }
        System.out.println("");
    }
    
    public void run(){
        try{
            BufferedReader stdReader = new BufferedReader(new InputStreamReader(System.in));
            int H = -1;            
            int W = -1;            
            String line = "";
            int tempH = 0;
			//(line = stdReader.readLine())!=null
            while(true) {
                if(W==-1 && !line.equals("")){
                    H = Integer.valueOf(line.split(" ")[0]);
                    W = Integer.valueOf(line.split(" ")[1]);
                    map = new String[H][W];
                }else if(!line.equals("0 0")){
                    setLine(tempH, line);
                    tempH += 1;
                }else if(line.equals("0 0")){
					solve();
					W = -1;
					H = -1;
					tempH = 0;
				}
            }
            stdReader.close();
        }catch(Exception e){
			e.getStackTrace();
        }
    }
    private void solve(){
        int person = 0;
        int[] point;
        while((point = getPointOfNotSearcherArea()) != null){
            search(point);
            person++;
        }
        System.out.println(person);
    }
    
    private void search(int[] point){
        int x = point[0];
        int y = point[1];
        String temp = map[x][y];
        map[x][y] = "_";
        for(int diff = -1;  diff<=1; diff++){
            if(x+diff>=0 && x+diff<map.length){
                if(map[x+diff][y].equals(temp)&&!map[x+diff][y].equals("_")){
                    int[] neoPoint = {x+diff, y};
                    search(neoPoint);
                }
            }
            if(y+diff>=0 && y+diff<map.length){
                if(map[x][y+diff].equals(temp)&&!map[x][y+diff].equals("_")){
                    int[] neoPoint = {x, y+diff};
                    search(neoPoint);
                }
            }
        }
    }

    private int[] getPointOfNotSearcherArea(){
        for(int i = 0; i < map.length; i++){
            for(int j = 0; j < map[0].length; j++){
                if(!map[i][j].equals("_")){
                    int point[] = {i,j};
                    return point;
                }
            }
        }
        return null;
    }
        
    private void setLine(int tempH, String input){
        for(int i = 0; i < map[tempH].length; i++){
            String entity = input.substring(i,i+1);
            map[tempH][i] = entity;
        }
    }
}

    

Compiler output:
Main.java:43: error: unreachable statement
            stdReader.close();
            ^
1 error
Language: Java

public class Main{
	private static int n;	//???
	private static int m;	//???
	private static char[][] map;
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		while (scanner.hasNextInt()) {
			n = scanner.nextInt();
			m = scanner.nextInt();
			if (n==0&&m==0) {
				break;
			}
			
			int step = 0;	//??°????¬???°
			map = new char[n][m];
			for (int i=0;i<n;i++) {
				String str = scanner.next();
				for (int j=0;j<m;j++) {
					map[i][j] = str.charAt(j);
				}
			}
			
			for (int i=0;i<n;i++) {
				for (int j=0;j<m;j++) {
					if (map[i][j]!='+') {
						dfs(i,j,map[i][j]);
						step++;
					}
				}
			}
			
			System.out.println(step);
		}
	}

	private static void dfs(int i, int j,char c) {
		map[i][j] = '+';
		//??????????????????---???????§??????????????????????????????\??????????????????????????????
		//for (int a=-1;a<2;a++) {
		//for (int b=-1;b<2;b++) {
		//------------------
		//???????????????????????§??¶??????
		int d[][] =  {{0,1},{0,-1},{1,0},{-1,0}};
		for (int a=0;a<4;a++) {
			//?§???¨????????????(nx,ny);
			int nx = i+d[a][0];
			int ny = j+d[a][1];
			//??????(nx,ny)???????????¨??¢???????????¶?????????????°´???
			if (nx<n&&nx>=0&&ny<m&&ny>=0&&map[nx][ny]==c) {
				dfs(nx,ny,c);
			}			
		}
	}
}

Compiler output:
Main.java:7: error: cannot find symbol
		Scanner scanner = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: cannot find symbol
		Scanner scanner = new Scanner(System.in);
		                      ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		while(true) {
			int H = in.nextInt();
			int W = in.nextInt();
			if(H == 0 && W == 0) return 0;

			in.nextLine();

			String[] map = new String[H + 200];
			String str = "";
			for (int i = 0; i < W + 2; i++) {
				str += ".";
			}
			map[0] = str;
			for (int i = 1; i <= H; i++) {
				String s = in.nextLine();
				map[i] = "." + s + ".";
			}
			map[H + 1] = str;

			solve(H, W, map);
		}
		return 0;
	}

	public static void print(String[] map, int H, int W) {
			for(int i=0;i<H+2;i++) {
			for(int j=0;j<W+2;j++) {
				System.out.print(map[i].charAt(j));
			}
			System.out.println("");
		}
	}

	public static void solve(int H, int W, String[] map) {
//		print(map, H, W);
        boolean visited[][] = new boolean[H+200][W+200];
		int ans = 0;
		for(int i=1;i<=H;i++) {
			for(int j=1;j<=W;j++) {
				if(!visited[i][j]) {
					dfs(visited, map, ""+map[i].charAt(j), i, j);
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

	public static void dfs(boolean[][] visited, String[] map, String key, int h, int w) {
		visited[h][w] = true;
		int di[] = {0, 0, -1, +1};
		int dj[] = {+1, -1, 0, 0};
		for(int i=0;i<4;i++) {
			int ni = h + di[i];
			int nj = w + dj[i];
			if(visited[ni][nj] == false && (""+map[ni].charAt(nj)).equals(key)) {
				dfs(visited, map, key, ni, nj);
			}
		}
	}

}

Compiler output:
Main.java:12: error: incompatible types: unexpected return value
			if(H == 0 && W == 0) return 0;
			                            ^
Main.java:30: error: incompatible types: unexpected return value
		return 0;
		       ^
2 errors
Language: Java

import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;

class Main {
	public static int main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);

		while(true) {
			int H = in.nextInt();
			int W = in.nextInt();
			if(H == 0 && W == 0) return 0;

			in.nextLine();

			String[] map = new String[H + 200];
			String str = "";
			for (int i = 0; i < W + 2; i++) {
				str += ".";
			}
			map[0] = str;
			for (int i = 1; i <= H; i++) {
				String s = in.nextLine();
				map[i] = "." + s + ".";
			}
			map[H + 1] = str;

			solve(H, W, map);
		}
		return 0;
	}

	public static void print(String[] map, int H, int W) {
			for(int i=0;i<H+2;i++) {
			for(int j=0;j<W+2;j++) {
				System.out.print(map[i].charAt(j));
			}
			System.out.println("");
		}
	}

	public static void solve(int H, int W, String[] map) {
//		print(map, H, W);
        boolean visited[][] = new boolean[H+200][W+200];
		int ans = 0;
		for(int i=1;i<=H;i++) {
			for(int j=1;j<=W;j++) {
				if(!visited[i][j]) {
					dfs(visited, map, ""+map[i].charAt(j), i, j);
					ans++;
				}
			}
		}
		System.out.println(ans);
	}

	public static void dfs(boolean[][] visited, String[] map, String key, int h, int w) {
		visited[h][w] = true;
		int di[] = {0, 0, -1, +1};
		int dj[] = {+1, -1, 0, 0};
		for(int i=0;i<4;i++) {
			int ni = h + di[i];
			int nj = w + dj[i];
			if(visited[ni][nj] == false && (""+map[ni].charAt(nj)).equals(key)) {
				dfs(visited, map, key, ni, nj);
			}
		}
	}

}

Compiler output:
Main.java:30: error: unreachable statement
		return 0;
		^
1 error