This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, Your statement (System.out.println) must be inside a method. You just can declare and initialize class variable and instance variable at that place. You can learn about that in the Java Language Specification
Correct me if i am wrong...
Joined: Nov 13, 2004
I dont know where to look specifically in JLS but i am assuming that you cant write System.out.println ina class ... you need to have that in a method...
if somebody can shed more light, i would be grateful... regards Prashanth
You can indeed not have any code outside a method or initializer block. The one exception to this are calls to new to initialize objects, and those calls can only contain literals as arguments if I'm not mistaken.