Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dan's Exam - Return Types

 
Vijay Albuquerque
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following question appears in Dan's Exam on Return Types:

The compiler ignores the semi-colon's after the method declaration statements. I cannot figure out why it ignores this !!!
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vijay Albuquerque:
The compiler ignores the semi-colon's after the method declaration statements. I cannot figure out why it ignores this !!!

The compiler doesn't really ignore the semi-colon. That's a perfectly legal statement in Java. Try the following program:

You'll find that the program compiles and executes fine. A semi-colon by itself is simply an empty statement.
Corey
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Corey McGlone:
You'll find that the program compiles and executes fine. A semi-colon by itself is simply an empty statement.

Ok... so everything our dear Corey said BEFORE this statement was perfectly correct... and if by "the program" he means the lil tid bit of code that he plopped in his post -- he's right -- it will compile... but the code that Vijay posted will NOT compile -- not because of the stray ;'s (like Corey said -- those are legal) but because of some errors with return types.
Ya know -- those bartender-types think they're so smart... sometimes ya just gotta show 'em that they're wrong.

Corey McGlone is still my hero.
[ January 02, 2003: Message edited by: Jessica Sant ]
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vijay,
The question is really about the return types. The semicolons are just typo errors.
The semicolons are viewed as empty statements and have no impact on the program. Even so, I'll remove them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic