• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Move implemenation out of main(String[ ] args)

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im looking for some guidance as to how i would go about moving implemenation out of main(String[ ] args). I have tried to do this a few times and all i seem to do is mess up my code.

 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Aretha Clark:
I have tried to do this a few times and all i seem to do is mess up my code.



Could you be more specific? How is it messing up your code? Are you getting compile time errors? Runtime errors/exceptions? Is it just not doing what you want it to do?

If you can post the code for what you have tried, and what errors you are getting, it'd be a little easier to assist you.
 
Master Rancher
Posts: 5109
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens if you move all your code out of main() to a Constructor for the class and insert a call to that constructor in main()?
 
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally you want to create a constructor for Dvdinventory and a function, something like process().

In your main, do something like
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic