• Post Reply Bookmark Topic Watch Topic
  • New Topic

Question on placement of ;

 
Ashish Anant Patil
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does " ;" in middle of program or loop mean?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15715
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an empty statement, and does nothing.

Can you give a specific code example?
 
Ashish Anant Patil
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for(int i=1;i<4;i++)
;
//more code...
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15715
73
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a loop that lets i increment from 1 to 3, but does nothing in each iteration of the loop. Nobody would write something like that in real code, if they know what they are doing.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!