• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling a function in a class without a Main

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Bartender
Posts: 242
27
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!  
 
reply
    Bookmark Topic Watch Topic
  • New Topic