It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Reg ; after a method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Reg ; after a method " Watch "Reg ; after a method " New topic

Reg ; after a method

Angela Narain
Ranch Hand

Joined: Apr 14, 2001
Posts: 327
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

Joined: Aug 07, 2001
Posts: 418
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.
Asma Zafar
Ranch Hand

Joined: May 11, 2001
Posts: 49
yeah ; just means an empty statement. Its not a CE.

Asma Zafar,
Sun Certified Programmer for Java2 Platform

Asma Zafar,<BR>Sun Certified Programmer for Java2 Platform
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
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

Joined: May 30, 2001
Posts: 328
If method() were an abstract method the ; would be necesary but without the curly braces.
abstract void method();


Raising Flares debut album 'Ignition' out now

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
I agree. Here's the link:
subject: Reg ; after a method
It's not a secret anymore!