Language: Java

import java.util.*;
import java.io.*;

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

        String str[] = br.readLine().split(" ");

        int n = Integer.parseInt(str[0]);
        int m = Integer.parseInt(str[1]);

        char mat[][] = new char[n][m];
        int start[][] = new int[n][m];
        int end[][] = new int[n][m];

        for(int i = 0; i < n; i++) {
            char c[] = br.readLine().toCharArray();
            for(int j = 0; j < m; ++j) {
                mat[i][j] = c[j];
            }
        }

        int rows[][] = new int[n][m+2];
        int cols[][] = new int[m][n+2];

        
        // for(int i = 0; i < n; i++) {
        //     rows[i] = new Vector<Integer>();
        // }

        // for(int i = 0; i < m; i++) {
        //     cols[i] = new Vector<Integer>();
        // }

        int ans = 0;

        for(int i = 0; i < n; i++) {
            int cnt = 0;

            rows[i][cnt++] = -1;
            for(int j = 0; j < m; j++) {
                if(mat[i][j] == '#') {
                    rows[i][cnt++] = j;
                }
            }
            rows[i][cnt++] = m;

            int l = 0, r = 1;

            for(int j = 0; j < m; j++) {
                if(mat[i][j] != '#') {
                    start[i][j] = rows[i][r] - rows[i][l];
                }
                else {
                    start[i][j] = 0;
                }
                if(j == rows[i][r]) {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < m; i++) {
            int cnt = 0;
            cols[i][cnt++] = -1;
            for(int j = 0; j < n; j++) {
                if(mat[j][i] == '#') {
                    cols[i][cnt++] = j;
                }
            }
            cols[i][cnt++] = n;

            int l = 0, r = 1;
            for(int j = 0; j < n; j++) {
                if(mat[j][i] != '#') {
                    end[j][i] = cols[i][r] - cols[i][l];
                }
                else {
                    end[j][i] = 0;
                }
                if(j == cols[i][r])  {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                ans = Math.max(ans, (start[i][j] + end[i][j]));
            }
        }

        System.out.println(ans - 3);
    }
} 

            char c[] = br.readLine().toCharArray();
            for(int j = 0; j < m; ++j) {
                mat[i][j] = c[j];
            }
        }

        Vector<Integer>[] rows = (Vector<Integer>[]) new Vector[n];
        Vector<Integer>[] cols = (Vector<Integer>[]) new Vector[m];

        
        for(int i = 0; i < n; i++) {
            rows[i] = new Vector<Integer>();
        }

        for(int i = 0; i < m; i++) {
            cols[i] = new Vector<Integer>();
        }

        int ans = 0;

        for(int i = 0; i < n; i++) {
            rows[i].add(-1);
            for(int j = 0; j < m; j++) {
                if(mat[i][j] == '#') {
                    rows[i].add(j);
                }
            }
            rows[i].add(m);

            int l = 0, r = 1;

            for(int j = 0; j < m; j++) {
                if(mat[i][j] != '#') {
                    start[i][j] = rows[i].get(r) - rows[i].get(l);
                }
                else {
                    start[i][j] = 0;
                }
                if(j == rows[i].get(r)) {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < m; i++) {
            cols[i].add(-1);
            for(int j = 0; j < n; j++) {
                if(mat[j][i] == '#') {
                    cols[i].add(j);
                }
            }
            cols[i].add(n);

            int l = 0, r = 1;
            for(int j = 0; j < n; j++) {
                if(mat[j][i] != '#') {
                    end[j][i] = cols[i].get(r) - cols[i].get(l);
                }
                else {
                    end[j][i] = 0;
                }
                if(j == cols[i].get(r))  {
                    l = r;
                    r += 1;
                }
            }
        }

        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                ans = Math.max(ans, (start[i][j] + end[i][j]));
            }
        }

        System.out.println(ans - 3);
    }
} 


Compiler output:
Main.java:100: error: class, interface, enum, or record expected
            char c[] = br.readLine().toCharArray();
            ^
Main.java:101: error: class, interface, enum, or record expected
            for(int j = 0; j < m; ++j) {
            ^
Main.java:101: error: class, interface, enum, or record expected
            for(int j = 0; j < m; ++j) {
                           ^
Main.java:101: error: class, interface, enum, or record expected
            for(int j = 0; j < m; ++j) {
                                  ^
Main.java:103: error: class, interface, enum, or record expected
            }
            ^
Main.java:107: error: unnamed classes are a preview feature and are disabled by default.
        Vector<Integer>[] cols = (Vector<Integer>[]) new Vector[m];
        ^
  (use --enable-preview to enable unnamed classes)
Main.java:110: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
        ^
Main.java:110: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                       ^
Main.java:110: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                              ^
Main.java:112: error: class, interface, enum, or record expected
        }
        ^
Main.java:114: error: class, interface, enum, or record expected
        for(int i = 0; i < m; i++) {
                       ^
Main.java:114: error: class, interface, enum, or record expected
        for(int i = 0; i < m; i++) {
                              ^
Main.java:116: error: class, interface, enum, or record expected
        }
        ^
Main.java:120: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
        ^
Main.java:120: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                       ^
Main.java:120: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                              ^
Main.java:122: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
            ^
Main.java:122: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                           ^
Main.java:122: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                                  ^
Main.java:125: error: class, interface, enum, or record expected
                }
                ^
Main.java:131: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
            ^
Main.java:131: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                           ^
Main.java:131: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                                  ^
Main.java:134: error: class, interface, enum, or record expected
                }
                ^
Main.java:137: error: class, interface, enum, or record expected
                }
                ^
Main.java:140: error: class, interface, enum, or record expected
                    r += 1;
                    ^
Main.java:141: error: class, interface, enum, or record expected
                }
                ^
Main.java:145: error: class, interface, enum, or record expected
        for(int i = 0; i < m; i++) {
                       ^
Main.java:145: error: class, interface, enum, or record expected
        for(int i = 0; i < m; i++) {
                              ^
Main.java:147: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
            ^
Main.java:147: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
                           ^
Main.java:147: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
                                  ^
Main.java:150: error: class, interface, enum, or record expected
                }
                ^
Main.java:155: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
            ^
Main.java:155: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
                           ^
Main.java:155: error: class, interface, enum, or record expected
            for(int j = 0; j < n; j++) {
                                  ^
Main.java:158: error: class, interface, enum, or record expected
                }
                ^
Main.java:161: error: class, interface, enum, or record expected
                }
                ^
Main.java:164: error: class, interface, enum, or record expected
                    r += 1;
                    ^
Main.java:165: error: class, interface, enum, or record expected
                }
                ^
Main.java:169: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                       ^
Main.java:169: error: class, interface, enum, or record expected
        for(int i = 0; i < n; i++) {
                              ^
Main.java:170: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                           ^
Main.java:170: error: class, interface, enum, or record expected
            for(int j = 0; j < m; j++) {
                                  ^
Main.java:172: error: class, interface, enum, or record expected
            }
            ^
Main.java:176: error: class, interface, enum, or record expected
    }
    ^
46 errors