wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Help Me Out: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Help Me Out:" Watch "Help Me Out:" New topic
Author

Help Me Out:

Prashanth Lingala
Ranch Hand

Joined: Nov 13, 2004
Posts: 66


Now My Question...


Please Explain???
Thank You For Your Time...


Have A Nice Day !!!
Martin Lerchster
Greenhorn

Joined: Nov 29, 2004
Posts: 10
because you are not able to call a function within a class and out of a function declaration !

within a class you are able to declare functions, vars .... but not to call a function, you have to call a function within a function declaration!

greetz
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
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...

thanks
daniel
Prashanth Lingala
Ranch Hand

Joined: Nov 13, 2004
Posts: 66
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...



and



if somebody can shed more light, i would be grateful...
regards
Prashanth
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help Me Out:
 
Similar Threads
Websphere Studio Error : MQJMS1061: Unable to deserialize object
Can we have more than one public class in a same program
Alternatives for Reflection
Inheritance Trouble
Error - ; expected