Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

why compiler treats for loop as incorrect

 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Below code works fine


but if remove initialisation for grade I am getting an error.





I understand that char cannot be empty but why its showing errors in for loop


 
author
Posts: 23919
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

somashaker goud wrote:
I understand that char cannot be empty but why its showing errors in for loop



Basically, once the compiler finds an error, it has to move on and find the next error. The problem with moving on and finding the next error, is that it is an error situation. The developer made a mistake, and all the compiler knows is that it is not conforming to specification. It can only guess on the mistake itself -- and hence, guess on where the mistake ends.

This is why you should always work on the first few compiler errors. Compilation errors that appear later may be false positives. And also, some compilation errors that "appear" later may not even be found.

Henry
 
Saloon Keeper
Posts: 9267
78
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The compiler is complaining about an empty character literal. This means that you have two single quotes back to back without a character in between them. Your second listing shows a single space between them so I'm assuming that you removed that prior to compiling.
 
Get out of my mind! Look! A tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic