Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling Multiple main methods in a Main  RSS feed

 
Pavan Chillara
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written a program in which main mathod is calling is some other main methods.But in that all the main methods are not called.
The code is as follows
 
Petrus Pelser
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can't see why this happens, everything looks ok. Are you sure?

PS: I assume MInterface is not an interface as an interface cannot contain static methods or be instantiated.
 
Pavan Chillara
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MyInterface is not an interface it is class only,The code for MyInterface is as follows

The code for MultipleMains is as follows
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
MultipleMains.main() calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() which calls MultipleMains.main() which calls MultipleMains.A() until finally, the execution stack is so high that the program terminates with a StackOverflowException. The other two main()s do get called -- they just get called first, before the screen fills up with other junk.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!