#Probably an easily answered noob question about Java structure
16 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @stark pilot! Please use
/closeor theClose Postbutton above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
You can define methods one after the other outside of your main method and call them from main, but they will be static methods.
If you create another class, you must create an object to invoke each method, generally.
methods are defined up top above the main method and called within the main method on bottom.
hope this helps
you can define methods anywhere tho
but it's recommended to put them above main for some reason
like what we had in c/cpp
Methods need to be defined directly inside a class. That's not quite "anywhere"
well, anywhere withtin the class body and outside of other method bodies
constructors, initializers, variable declaration initializing expressions...
and other shit
anywhere directly in a type body
if you want to implement something in java, a spec of functions is generally not enough, since java is so heavily and fundamentally OOP. you could make all your method static in the main method to kinda disregard OOP, but then you may as well not use java.
i think you should go back to your design and add OOP, then you can implement that more directly into java.