Win a copy of Design for the Mind this week in the Design 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: 34178
340
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: 34178
340
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