Language: Java

for(int i=0;i<W;i++){
            for(int j=0;j<H;j++){
                A[i][j]=sc.next();
                counter[i][j]=0;
            }
        }
        for(int i=0;i<W;i++){
            for(int j=0;j<H;j++){
                while(i<W-1){
                    i++;
                    counter[i][j]++;
                    if(A[i][j].equals("#")){
                        break;
                    }
                }
                while(j<=H-1){
                    j++;
                    counter[i][j]++;
                    if(A[i][j].equals("#")){
                        break;
                    }
                }
            }
        }
        int max=0;
        for(int i=0;i<W;i++){
            for(int j=0;j<H-1;j++){
                if(counter[i][j]<counter[i][j+1]){
                    max=counter[i][j+1];
                }

Compiler output:
Main.java:1: error: class, interface, enum, or record expected
for(int i=0;i<W;i++){
^
Main.java:1: error: class, interface, enum, or record expected
for(int i=0;i<W;i++){
            ^
Main.java:1: error: class, interface, enum, or record expected
for(int i=0;i<W;i++){
                ^
Main.java:2: error: class, interface, enum, or record expected
            for(int j=0;j<H;j++){
                        ^
Main.java:2: error: class, interface, enum, or record expected
            for(int j=0;j<H;j++){
                            ^
Main.java:4: error: class, interface, enum, or record expected
                counter[i][j]=0;
                ^
Main.java:5: error: class, interface, enum, or record expected
            }
            ^
Main.java:7: error: class, interface, enum, or record expected
        for(int i=0;i<W;i++){
                    ^
Main.java:7: error: class, interface, enum, or record expected
        for(int i=0;i<W;i++){
                        ^
Main.java:8: error: class, interface, enum, or record expected
            for(int j=0;j<H;j++){
                        ^
Main.java:8: error: class, interface, enum, or record expected
            for(int j=0;j<H;j++){
                            ^
Main.java:11: error: class, interface, enum, or record expected
                    counter[i][j]++;
                    ^
Main.java:12: error: class, interface, enum, or record expected
                    if(A[i][j].equals("#")){
                    ^
Main.java:14: error: class, interface, enum, or record expected
                    }
                    ^
Main.java:18: error: class, interface, enum, or record expected
                    counter[i][j]++;
                    ^
Main.java:19: error: class, interface, enum, or record expected
                    if(A[i][j].equals("#")){
                    ^
Main.java:21: error: class, interface, enum, or record expected
                    }
                    ^
Main.java:26: error: class, interface, enum, or record expected
        for(int i=0;i<W;i++){
        ^
Main.java:26: error: class, interface, enum, or record expected
        for(int i=0;i<W;i++){
                    ^
Main.java:26: error: class, interface, enum, or record expected
        for(int i=0;i<W;i++){
                        ^
Main.java:27: error: class, interface, enum, or record expected
            for(int j=0;j<H-1;j++){
                        ^
Main.java:27: error: class, interface, enum, or record expected
            for(int j=0;j<H-1;j++){
                              ^
Main.java:30: error: class, interface, enum, or record expected
                }
                ^
23 errors