java - Error " '(' expected" on line 5 -


here program code. getting error says

'(' expected, on line 5 [below public void work, on d braces].

i don't understand corrected there.

import java.util.*; class matrix {     public void work     {         scanner scan= new scanner(system.in);         int n, i, j;         char a, b, c;         system.out.println("enter size: ");         n=scan.nextint();         int m[][]= new int[n][n];         system.out.println("first character ");         a= scan.nextchar();         system.out.println("second character ");         b= scan.nextchar();         system.out.println("third character ");         c= scan.nextchar();         if(n<=10)         {         for(i=0; i<n; i++)         {             for(j=0; j<n; j++)             {                 if((i==j)||(i+j==n-1))                 {                     system.out.print(c);                 }                 else if(((i>j)&&((j==0)||(j==1))) || ((i<j)&&((j==n-2)||(j==n-1))))                 {                     system.out.print(b);                 }                 else if(((i<j)&&((i==0)||(i==1))) || ((i>j)&&((i==n-2)||(i==n-1))))                 {                     system.out.print(a);                 }             }         }     }     else     system.out.println("size out of range");     } } 

you developing java , syntaxt incorrect

public void work { 

basically not compiling because need add parenthesis if don pass parameter method...

do instead

public void work(){ 

and fine!


Comments