if statement - 1. java ')' expected error + 2. 'else' without 'if' error -


the error ')' expected encountered on line 8; , error 'else' without 'if' found on line 9. part of method. beginning declares needed variable (name1, name2, count), , states possible exceptions when reading file. @ point, program should reading file in order compare names written in file.

 while ( ! textio.eof() )             {                 name1.compareto(name2);                 if (name1.equals(name2));                 count++;             } while ( ! textio.eof() );          if (count >= 0){         system.out.println("you encountered" + count "identical names.");     else         system.out.println("there no name encountered more once.");     } 

remove ; @ end of if statement. ; ends if statement.

if (name1.equals(name2)) count++; 

and add braces if , else separately.

if (count >= 0) {     system.out.println("you encountered" + count + "identical names."); } else {     system.out.println("there no name encountered more once."); }    

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -