Reputation: 21
im attempting to pass a 2 dimensional array of characters to a method. but keep ending up with a .class expected when compiled. there is a lot of extra code i excluded cause no error
2 errors found: File: /home/cmehmen/CSC 202/NewFolder/TicTacToe.java [line: 741] Error: '.class' expected File: /home/cmehmen/CSC 202/NewFolder/TicTacToe.java [line: 741] Error: ';' expected
char [][] matrix2 ={
{' ',' ',' '},
{' ',' ',' '},
{' ',' ',' '},
};
//end main
vicCheck (char[][]matrix2);
public static void vicCheck(){
if(matrix2 [0][0] == 'X' && matrix2 [0][1] =='X' && matrix2 [0][2] =='X'){
System.out.println("Player X Wins");
}
if(matrix2 [1][0] == 'X' && matrix2 [1][1] =='X' && matrix2 [1][2] =='X'){
System.out.println("Player X Wins");
}
if(matrix2 [2][0] == 'X' && matrix2 [2][1] =='X' && matrix2 [2][2] =='X'){
System.out.println("Player X Wins");
}
return;
}
Upvotes: 0
Views: 46
Reputation: 201409
Based on what you've posted, you appear to be confused about actual parameters and formal parameters and the syntax thereof -
// vicCheck (char[][]matrix2);
vicCheck (matrix2); // <-- actual parameters
and
// public static void vicCheck(){
public static void vicCheck(char[][]matrix2){ // <-- formal parameters
Upvotes: 1