I've got this code
int result=0;
switch ((int)(Math.random()*7)+1){
case 1:
if((tArray[0][4]=='X')||(tArray[0][5]=='X')||(tArray[1][4]=='X')||(tArray[1][5]=='X'))
break;
else{
tArray[0][4]='H';
tArray[0][5]='H';
tArray[1][4]='H';
tArray[1][5]='H';
result=1;
break;
}
(declared tArray variable in method parameters)
and when I compile its throwing error:else without if.
think I'm probably missing something simple but cant figure it out.
also this is only one of 7 cases which are all similarly throwing errors.
Tried putting the break after the if-else and still the same problem.
also tried putting braces around the first break to no avail.
beginner programmer so go easy on me :).
(sorry if repeat question)
Aucun commentaire:
Enregistrer un commentaire