• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java :The Complete Reference (Herb Schildt) p 542

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

On this page in the source code for an example of Observer interface for a class of Observable type lists a for-loop inside a method. The for-loop is shown thus: for( ; period>=0; period--). This the Netbeans IDE is flagging off as "Illegal start of expression.". Hence the program does not compile. What should be done?

OCA/OCP Java SE7 Programmer I & II study guide on p326 through 328 list various formats for the for loop wherein : for( ; ; ) is an endless loop. The Netbeans IDE passes it as "legal" . Then there is a for( ; i < 10 ; ) with an inside-the-loop iteration expression. But this usage aslo is flagged as "Illegal".

I have Emailed a query to the author Herb Schildt, but in all likelihood this may not be answered in the near future. But I am working all by myself for certification. Please help.

Thanks in advance.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Could you post more of the code, or all of it if it's not too long? Especially the line before the for loop. And remember to UseCodeTags (←click).
 
Mahadeva Sarma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code has since worked! Now, what did I do? First I modified the for-loop statement to for( ; ; ) from what was given, but I was hesitating to run the program for that would be an infinite loop-anyway it wouldn't have mattered for I was working inside the IDE with the safety of an "abort" button. After once modifying this way I re entered the same i.e for( ; period>=0; period--) and surprised to see that the NDE didn't flag it off as "illegal start of expression". Gingerly I came to the end of the source file chose Run File. The program ran without problems and produced the output given in the book.

Could we call it as a case of RESET WIND-UP as in Instrumentation Controllers?

Anyway, I thank you very much for the Immediate Attention given to my query. Thanks a ton! Today morning one more such situation but that was due to an entry error the program was running without an end esp one which was executed at the Command Line. Tried all the usual keys for aborting it. But what worked was simply closing the command window(DOS-mode) and reopening it!!
Well on my way to getting ready for certification!
 
Ranch Hand
Posts: 89
Python C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would suggest you not to use an IDE until you're well versed with the Java language. Please read this.
 
Mahadeva Sarma
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Ashwin,

You are right.I agree with you and HFJ K&B also strongly advises against the use of an IDE. And rightly so. I have since been extensively using the Command Line and the npp editor. This gives a lot of practice and convenience, while preparing source file(I mean the npp editor). But initially I had started with Netbeans IDE and had done quite a lot of my learning in that env. The advantage is you are helped by the IDE's features, avoiding some elementary pitfalls. Now, having gained quiet confidence I am already on Command Line. Thank you.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic