• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reg ; after a method

 
Angela Narain
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both the below codes compile fine
What is the use of ; in the below code ?
abstract class test
{

void method(){};
}

abstract class test
{

void method(){}
}
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not very sure, but that could be an empty statement . Even if u put a ;anywhere in the code, it copiles. So putting a ; in front of a method signifies nothing but just an emply stmt...
Correct me if i am wrong.
Rashmi
 
Asma Zafar
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yeah ; just means an empty statement. Its not a CE.

------------------
Asma Zafar,
Sun Certified Programmer for Java2 Platform
 
Desai Sandeep
Ranch Hand
Posts: 1157
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela,
Semicolon ( after the curly brace (}) is not required.Even if you put it the compiler will not report an error.It is used to mark an end of a declaration or a statement.
-- Sandeep
SCJP2, OCSD(Oracle JDeveloper), OCED(Oracle Internet Platform)
[This message has been edited by Desai Sandeep (edited September 01, 2001).]
 
Terence Doyle
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI,
If method() were an abstract method the ; would be necesary but without the curly braces.
abstract void method();

Terry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic