Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

out.print("hi");;

 
pippiri venu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.print("hi");;

hi,
can u tell me
here why this one is not giving err? (i used ;

 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
correct, i too noticed this lately. the reason is that perhaps, after reading the ";" the compiler looks for the next statement which can be a blank statement ending in ";" so its okay.
 
pippiri venu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after reading the ";" the compiler looks for the next statement
which can be a blank statement ending in ";" so its okay.

IF IT IS TRUE THEN WHY

out.print("Hi..");fff; GIVES ERR?
 
Neeraj Macker
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by pippiri venu:
after reading the ";" the compiler looks for the next statement
which can be a blank statement ending in ";" so its okay.

IF IT IS TRUE THEN WHY

out.print("Hi..");fff; GIVES ERR?


because fff; is not a valid statement in java.have u defined variable fff somewhere?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64973
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to Java in General (beginner).
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It might help you to understand that Java allows you to write more than one instruction per line.
 
Clay Adkerson
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesnt matter how messy your code looks (although it is best to keep it organized. As long as you have all the correct ; and correct syntax it should work. The ';' tells the program that this is the end of the command. It reads everything up to the semi-colon (starting from the last point it left off) so you could have all your code on one line if you wanted to.

As to the fff; thing the syntax must be correct.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic