This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

basic question

 
Saumyaraj Zala
Ranch Hand
Posts: 56
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the things that comes inside a class and outside a method.....for example the declaration of instance variable....Can i write statements outside a method??? Till now I wrote my programs with instance variables outside the method but what more can we write outside a method?? Is method necessary for writing statements??? Can i write my java program without method??? Please help...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write static or instance variable instantiation blocks outside a method. You can't write your whole program without a method though as programs kick off with a main() method.
 
Saumyaraj Zala
Ranch Hand
Posts: 56
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But i am not telling that i will not use the main method...i know about its importance
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can i write my java program without method???

You asked if you could write a program without any methods.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic