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

Calling a function in a class without a Main  RSS feed

 
David Vorpe
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

You all have probably seen this type of code before (message array) more times than I have typed it this week.  When I have a main argument for this code, it works perfectly.  However, my main argument is in another project and I am just calling this functionality into the main {MessageArray bob = new MessageArray;}.  When I remove the main argument from this code, I am so errored it isn't funny-every line.  I use NetBeans 8.1 IDE (class mandated).  Here is the code to create the array list:


It is probably something stupidly easy that I have probably done 4 times for this Masters class alone.  I just can't remember how I did it.

Thanks, as always, for your help!
 
Zachary Griggs
Ranch Hand
Posts: 83
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code is outside of a method, so it can't compile. If you put it in a method, you'll be able to compile and use it:

 
David Vorpe
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Zachary Griggs wrote:That code is outside of a method, so it can't compile. If you put it in a method, you'll be able to compile and use it:



Aw, geez!  I knew it!  Thank you very much! 
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!