File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help Me Out:

 
Prashanth Lingala
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Now My Question...


Please Explain???
Thank You For Your Time...
 
Martin Lerchster
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 582
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic