File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes return statement 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 "return statement" Watch "return statement" New topic

return statement

Bin Zhao
Ranch Hand

Joined: Oct 04, 2000
Posts: 73
Khalid's book said return; can exist in initializers(P149).But when I compile the following code,the compiler complains
public class MQ7
int i=0;
public MQ7()

public static void main(String args[])
MQ7 tf = new MQ7();
Did I miss something?
zulfiqar raza
Ranch Hand

Joined: Oct 18, 2000
Posts: 81
In the errata for Khalid, the workds 'and initializer' have been removed. So you are right, you can't use it in initializers.
Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101
Yes u did, u cannot do this kind of operation within the body of class itself, it has to b within a method, constructor or a
main body for ot to work...
I agree. Here's the link:
subject: return statement
jQuery in Action, 3rd edition