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

0 votes
asked Jun 25 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

+1 vote
answered Jun 26 by Peter Minarik (12,220 points)
edited Jun 26 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.
...