This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

return statement

 
Bin Zhao
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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;
{
i=8;
return;
}
public MQ7()
{
i=10;
return;
}

public static void main(String args[])
{
MQ7 tf = new MQ7();
}
}
Did I miss something?
 
zulfiqar raza
Ranch Hand
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 101
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic