0

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;
  }
2
  • can't see a acceptable char array parameter in vicCheck() method Commented Sep 9, 2014 at 2:04
  • This has quite a few syntax errors. You may want to go read about how to create methods with parameters... Commented Sep 9, 2014 at 2:10

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

@madhawapriyashantha Not necessarily. It only has to be in scope for the call.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.