what should I do to compile this ? it sayis you need one main class .

0 votes
asked 6 days ago by Qrm Qrm (120 points)
private void substitute2DArray(){
    int row , col , k ;
    char tmp ;
    char[] strSAM = {'I','B','M','I','B','M'};
    for(row=0;row<str2D.length;row+=2){
        k =1;
        for(col=0;col<str2D[row].length;col++){
            tmp = str2D[row++][col];
            if(col>2){
                str2D[row-1][col]=strSAM[col];
            } else{
                str2D[row-1][col]=str2D[row][col];
            }
            if(col%2>0){
                str2D[row--][col]=tmp;
            }else{
                str2D[row--][col]=(char)(tmp+1);
            }
            k++;
        }
    }
}

1 Answer

0 votes
answered 6 days ago by Peter Minarik (1,950 points)
edited 6 days ago by Peter Minarik

Your code's structure should look something like this:

public class Main
{
    private void substitute2DArray()
    {
        // Implement your code here
    }

    public static void main(String[] args)
    {
        substitute2DArray();
    }
}

That being said, your code still would not compile, but at least, you will see compilation errors that make sense now (such as str2D is an undefined variable).

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...