• Post Reply Bookmark Topic Watch Topic
  • New Topic

main  RSS feed

 
Ranch Hand
Posts: 191
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we call main method from any other method or any other part of the code?
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure. Main is just a public static method like any other.
In general, though, it's not usually a particularly good idea. A much better approach is usually to write a method which takes appropriate parameters and does what you want. Then you can call that from main, and from wherever else you want:
 
I am mighty! And this is a mighty small ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!