This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

main  RSS feed

 
Vineela Devi
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?
 
Frank Carver
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:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!